简体   繁体   English

ASP.NET MVC 2 使用 Visual Studio 2010。通过 web.config 更改角色管理器

[英]ASP.NET MVC 2 using Visual Studio 2010. Changing the Roles Manager through web.config

I have implemented my own custom Role manager object.我已经实现了我自己的自定义角色管理器 object。 When I run my web app using the visual studio version of IIS, it works fine.当我使用 Visual Studio 版本的 IIS 运行我的 web 应用程序时,它工作正常。 I can see the username and I can drill into my Role Manager class and see what it's doing.我可以看到用户名,并且可以深入了解我的角色管理器 class 并查看它在做什么。 When I debug the app using IIS 7, HttpContext.Current.User.Identity.Name is blank and it does not use my Role Manager class when determining what roles my user has.当我使用 IIS 7 调试应用程序时,HttpContext.Current.User.Identity.Name 为空白,并且在确定我的用户具有哪些角色时,它不使用我的角色管理器 class。 I've checked that all my dlls are in the bin directory.我检查了我所有的 dll 都在 bin 目录中。

I'm guessing that the problem is on IIS 7. What do I need to configure on IIS 7 to make this work and to make it use my Role manager?我猜问题出在 IIS 7 上。我需要在 IIS 7 上配置什么才能使其工作并使用我的角色管理器?

Here is a snippet of the web.config that sets the role manager.这是设置角色管理器的 web.config 的片段。

<membership>
  <providers>
    <clear />
  </providers>
</membership>
<roleManager defaultProvider="HyperionRoleProvider" enabled="true">
  <providers>
    <clear />
    <add name="HyperionRoleProvider" type="Census.BUD.Common.HyperionRoleProvider" applicationName="/" />
  </providers>
</roleManager>

From:从:

http://learn.iis.net/page.aspx/528/how-to-use-the-sample-read-only-xml-membership-and-role-providers-with-iis-70/ http://learn.iis.net/page.aspx/528/how-to-use-the-sample-read-only-xml-membership-and-role-providers-with-iis-70/

"These samples are excellent for use with IIS 7.0 for demonstration or test Web sites, but they don't work as-written with IIS 7.0 because of the way that IIS 7.0's security is designed. The original instructions allowed you to deploy the sample membership/role providers into the App_Code folder of your Web site, but IIS 7.0 requires that providers are registered in the Global Assembly Cache (GAC) before they can be deployed. With that in mind, the following steps will walk you through compiling and deploying the read-only XML providers on a development system." "These samples are excellent for use with IIS 7.0 for demonstration or test Web sites, but they don't work as-written with IIS 7.0 because of the way that IIS 7.0's security is designed. The original instructions allowed you to deploy the将成员资格/角色提供程序示例放入 Web 站点的 App_Code 文件夹中,但 IIS 7.0 要求提供程序在部署之前在全局程序集缓存 (GAC) 中注册。考虑到这一点,以下步骤将引导您完成编译和在开发系统上部署只读 XML 提供程序。”

Make sure your assembly is in the GAC确保您的程序集在 GAC 中

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

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