繁体   English   中英

是否可以在asp.net CORE中将用户ID转换为int?

[英]Is it possible to convert User Id to int in asp.net CORE?

将用户ID更改为int可以帮助我添加一个“编辑用户”页面,以便能够编辑用户信息等,但是我在应用程序中的其他功能存在问题,因为它们使用字符串作为ID而不是int。 这是我已经尝试过的:

public class ApplicationUser : IdentityUser<int>

public class ApplicationRole : IdentityRole<int>

public class ApplicationDbContext : IdentityDbContext<ApplicationUser, ApplicationRole, int>

通过遵循这个toturial 这里

这将起作用,但是会弄乱应用程序中的“帐户”和“管理”控制器,尤其是以下几行:

var callbackUrl = Url.ResetPasswordCallbackLink(user.Id, code, Request.Scheme);

var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme);

var info = await _signInManager.GetExternalLoginInfoAsync(user.Id);

这些给出的错误表明它们无法从字符串转换为int,这是可以理解的。 这是否意味着不可能将Id从字符串转换为int?

  1. 检查方法定义 GetExternalLoginInfoAsync (string expectedXsrf = null)不希望将用户ID作为参数。 它获取当前登录的外部登录信息。

  2. 至于ResetPasswordCallbackLinkEmailConfirmationLink方法-您只需执行user.Id.ToString()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM