2023-02-16 313
我正在研究asp.net mvc核心应用程序.我有带有用户和角色表的自定义数据库.我想使用与自定义表的ASP.NET身份,以便我不必使用aspnetusers,aspnet角色表.如何使用ASP.NET身份和ASP.NET核心(ASP.NET核心)
祝你好运! :)
最后几天我刚刚经历了这个过程.我已经工作了,但它对一些阶段非常痛苦.
简而言之:
此链接将帮助您:
https://www. ASP.NET/iderity/overview/extensibility/overview-of-custom-storage-providers-for-asaspnetiateity
您可以使用cookie中间件身份验证.
在 startup.cs中您添加
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AuthenticationScheme = "MyCookieMiddlewareInstance",
LoginPath = new PathString("/Account/Unauthorized/"),
AccessDeniedPath = new PathString("/Account/Forbidden/"),
AutomaticAuthenticate = true,
AutomaticChallenge = true
});
在您的代码中,验证用户名和密码后,向登录您调用
await HttpContext.Authentication.SignInAsync("MyCookieMiddlewareInstance", principal);
和签名
await HttpContext.Authentication.SignOutAsync("MyCookieMiddlewareInstance");
请参阅 Microsoft网站更多详细信息
以上所述是小编给大家介绍的使用带有自定义表格的aspnet身份,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对77isp云服务器技术网的支持!
原文链接:https://77isp.com/post/33805.html
=========================================
https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。
数据库技术 2022-03-28
网站技术 2022-11-26
网站技术 2023-01-07
网站技术 2022-11-17
Windows相关 2022-02-23
网站技术 2023-01-14
Windows相关 2022-02-16
Windows相关 2022-02-16
Linux相关 2022-02-27
数据库技术 2022-02-20
抠敌 2023年10月23日
嚼餐 2023年10月23日
男忌 2023年10月22日
瓮仆 2023年10月22日
簿偌 2023年10月22日
扫码二维码
获取最新动态