asp.net成员资格 – 在Application_AuthenticationRequest设置Th
发布时间:2020-12-15 20:55:42 所属栏目:asp.Net 来源:网络整理
导读:在Application_AuthenticationRequest的global.asax文件中,我将Thread.CurrentPrincipal设置为自定义主体.我还将HttpContext.Current.User设置为相同的主体. 但是后来在应用程序中,当我需要将Thread.CurrentPrincipal强制转换为我们的自定义类型时,我收到运
在Application_AuthenticationRequest的global.asax文件中,我将Thread.CurrentPrincipal设置为自定义主体.我还将HttpContext.Current.User设置为相同的主体.
但是后来在应用程序中,当我需要将Thread.CurrentPrincipal强制转换为我们的自定义类型时,我收到运行时错误说: Thread.CurrentPrincipal是如何重置为RolePrincipal的,更重要的是我如何将它保存在我们在global.asax中设置的CustomPrincipal中 提前致谢 解决方法
你肯定已经解决了你的问题但是以防万一,如果你使用ASP.NET的RoleProvider,RoleManagerModule会覆盖FormsAuthenticationModule创建的GenericPrincipal对象,并在PostAuthenticateRequest期间用RolePrincipal对象替换它:
http://www.asp.net/Learn/Security/tutorial-11-vb.aspx (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – MVC – 用户必须在IIS Recycle上重新认证
- asp.net-mvc – 如何在发布期间跳过文件夹上的删除?
- asp.net-mvc – 用于MVC2的ASP.Net MVC期货更新
- ASP.NET:web.config在哪里/如何缓存?
- asp.net-mvc – 如何在单个视图中使用两个表单
- asp.net – LinkBut??ton不会在click()上调用
- asp.net – 部分查看并将数据传递给布局MVC3
- asp.net-mvc – 文件输入MVC 3所需的客户端验证
- asp.net-mvc – ASP.net MVC路由参数异常
- asp.net-mvc-3 – 如何在asp.net mvc3中添加一组单选按钮