简体   繁体   English

如何在IIS管理器中为ASP.NET 4.0应用程序添加用户?

[英]How to add users in IIS Manager for an ASP.NET 4.0 application?

I have installed an ASP.NET 4.0 Web forms application in IIS 7.5. 我在IIS 7.5中安装了ASP.NET 4.0 Web窗体应用程序。 If I set the application pool to DefaultAppPool (.NET Framework 2.0) I get the icons for Providers, .NET-Roles and .NET-Users displayed on the configuration page for the application in IIS Manager and I can manage users and roles within IIS. 如果我将应用程序池设置为DefaultAppPool (.NET Framework 2.0),我会在IIS管理器中的应用程序配置页面上显示Providers,.NET-Roles和.NET-Users的图标,我可以在IIS中管理用户和角色。 (I'm using Forms authentication.) (我正在使用Forms身份验证。)

But if I set the application pool to ASP.NET v4.0 I get a problem: Double clicking on the icons for Users or Roles in IIS Manager throws an error telling me that I cannot use these features since the providers could not be determined as trusted. 但是,如果我将应用程序池设置为ASP.NET v4.0,则会出现问题:双击IIS管理器中的用户或角色图标会引发错误,告诉我我无法使用这些功能,因为提供程序无法确定为值得信赖的。 If I set in administration.config in the trustedProviders section allowUntrustedProviders="true" and double click again on one of the icons I get the error that the assembly System.Web, Version 4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a could not be found. 如果我在trustedProviders部分中的administration.config中设置allowUntrustedProviders =“true”并再次双击其中一个图标,我会收到程序集System.Web,版本4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a的错误被发现。 If I restart IIS Manager the icons disappear completely. 如果我重新启动IIS管理器,图标将完全消失。

.NET Framework 4.0 is definitely installed. 绝对安装了.NET Framework 4.0。 So this is all quite confusing. 所以这一切都让人很困惑。 I know that .NET 4 uses another GAC than the old one for .NET 2-3. 我知道.NET 4使用的是另一个GAC而不是.NET 2-3的旧GAC。 Could it be possible that IIS Manager is not able to find the new GAC for .NET 4? 是否有可能IIS管理器无法找到新的GAC for .NET 4? Do I have to add perhaps some of the new 4.0 assemblies to administration.config ? 我是否必须将一些新的4.0程序集添加到administration.config中 Is there another way to add users and roles instead of IIS? 是否有另一种方法来添加用户和角色而不是IIS?

Thank you for help in advance! 提前感谢您的帮助!

There is a simple work around that is much easier than building administration pages. 有一个简单的解决方法比构建管理页面容易得多。

  1. Create a new site on your server. 在您的服务器上创建一个新站点。 You can name it MembershipAdminstrationYourActualSiteName. 您可以将其命名为MembershipAdminstrationYourActualSiteName。 Binding does not matter as you will not be executing any pages on this site, but make sure it is running in the 2.0 default application pool. 绑定无关紧要,因为您不会在此站点上执行任何页面,但请确保它在2.0默认应用程序池中运行。

  2. Copy the web.config from your 4.0 site to the folder for the new site. 将web.config从4.0站点复制到新站点的文件夹。 Edit the file removing everything except the connectionString, authentication, memebership, roleManager and profile sections. 编辑文件,删除除connectionString,authentication,memebership,roleManager和profile部分之外的所有内容。

  3. Now in IIS Manager access .NET Roles and .NET Users. 现在在IIS管理器中访问.NET角色和.NET用户。 Assuming you correctly edited the web.config file you should see the users and roles for your 4.0 application. 假设您正确编辑了web.config文件,您应该会看到4.0应用程序的用户和角色。

Unfortunately, currently those features are not supported if your Application Pool is using .NET 4.0 since that would require IIS Manager to load the .NET 4.0 framework in order to call the right providers (and that is why .NET Users/Membership, .NET Roles, etc), and it is not possible since IIS Manager is a .NET 2.0 application. 遗憾的是,如果您的应用程序池使用.NET 4.0,则目前不支持这些功能,因为这需要IIS管理器加载.NET 4.0框架才能调用正确的提供程序(这就是.NET Users / Membership,.NET的原因)角色等),因为IIS管理器是.NET 2.0应用程序所以不可能。

So for now there is no good workaround, other than changing your Application Pool temporarily to 2.0 and adding them and then switching back to 4.0. 所以目前没有好的解决方法,除了暂时将应用程序池更改为2.0并添加它们然后切换回4.0。 But of course you should not do this unless its just a development machine. 但是,除非它只是一台开发机器,否则你不应该这样做。

Otherwise you could build a page using the CreateUserWizard control and use the built-in Login controls from ASP.NET which should be a one line (of markup) to get similar functionality. 否则,您可以使用CreateUserWizard控件构建页面,并使用ASP.NET中的内置Login控件,它应该是一行(标记)以获得类似的功能。

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

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