2023-02-16 309
在Application_AuthenticationRequest中,我将Thread.CurrentPrincipal设置为自定义主体.我还将HttpContext.Current.User设置为同一主体.
但是,当我需要将Thread.CurrentPrincipal施放到我们的自定义类型时,我稍后稍后,我会得到一个运行时错误说:
无法施放”system.web.security.rolepipal”类型的对象以键入”ofcustomprincipal”.
thread.currentprinciplipips如何重置为角色突变,并且更多到点如何将其保留在Global.asax
中的CustomPrincipal中.
提前感谢
您肯定已经解决了您的问题,但是,如果您使用的是从ASP.NET中使用RoleProvider,则rolemanagermodule覆盖了FormsAuthenticationModule创建的泛gener incpipal对象,并在PostauthenticateRequest期间将其替换为角色官方对象:
http://www.asp.net/learn/security/tutorial-11 -vb.aspx
总结,快速修复是在application_onpostauthenticatereRequest处理程序上执行您的主体和身份替换.
请验证是否已为IIDENTITY和IPRINCIPAL接口实现了一个类,然后您正在使用以下代码的内容来分配当前PRINCIPAL.
Dim userIdentity As CustomIdentity
userIdentity = New CustomIdentity(username, True,"forms", sessionId)
Dim principal As New CustomPrincipal(userIdentity, arrRoles)
HttpContext.Current.User = principal
System.Threading.Thread.CurrentPrincipal = principal
以上所述是小编给大家介绍的在Application_AuthenticationRequest中设置的Thread.CurrentPrincipal在应用程序中后来没有被设置。,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对77isp云服务器技术网的支持!
原文链接:https://77isp.com/post/33994.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日
扫码二维码
获取最新动态