问题
Trying to use this code on ASP.NET Core 2.0
ApplicationUser MyUser = await _userManager.FindByNameAsync(model.Email);
var Code = await _userManager.GenerateChangePhoneNumberTokenAsync(MyUser, model.MobileNumber);
Results for variable "Code" is this instead of 6 digits.
CfDJ8Kjv6NuVfg5GkZ9ZEJRMBG2BxkZ4fnbwTfkq5335ft3Lm0sCl7uaRXFce+uDMtXC8wgdoiocyXV4nGlBz25tkbZr4JvZ6/1gk6EenJKmkq2of3XXfK/xMWE/M2aqmkz9OJpOe75Wz+xlmgq/HKZWtEgw17iQOULD3znVLtvr4t9Dche7u6N2YfrnP3hGxjwZJAaxmQksYc8ffO1m6xZNFCfZhfJsqG8JV+BgNp+5Bzk91d8PijFSyNADsXjq6G+w+g==
It works on ASP.NET Core 1.1.
Am I doing something wrong here?
回答1:
This is a confirmed bug, hopefully we'll see a patch very soon for this...
See: https://github.com/aspnet/Identity/issues/1388
EDIT 2017-09-21
As a workaround, add the following configuration in ConfigureServices
:
services.AddIdentity<ApplicationUser, IdentityRole>(o =>
{
//other stuff
o.Tokens.ChangePhoneNumberTokenProvider = "Phone";
});
EDIT 2018-01-07
As of .NET Core 2.0.3, this has been patched and the workaround is no longer necessary.
来源:https://stackoverflow.com/questions/45818588/generatechangephonenumbertokenasync-on-asp-net-core-2-0