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

16,853

Solution 1

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.

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. 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.

Solution 2

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. 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. Copy the web.config from your 4.0 site to the folder for the new site. Edit the file removing everything except the connectionString, authentication, memebership, roleManager and profile sections.

  3. Now in IIS Manager access .NET Roles and .NET Users. Assuming you correctly edited the web.config file you should see the users and roles for your 4.0 application.

Share:
16,853
Slauma
Author by

Slauma

Updated on June 03, 2022

Comments

  • Slauma
    Slauma about 2 years

    I have installed an ASP.NET 4.0 Web forms application in IIS 7.5. 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. (I'm using Forms authentication.)

    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. 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. If I restart IIS Manager the icons disappear completely.

    .NET Framework 4.0 is definitely installed. So this is all quite confusing. I know that .NET 4 uses another GAC than the old one for .NET 2-3. Could it be possible that IIS Manager is not able to find the new GAC for .NET 4? Do I have to add perhaps some of the new 4.0 assemblies to administration.config? Is there another way to add users and roles instead of IIS?

    Thank you for help in advance!

  • Slauma
    Slauma about 14 years
    Thanks for your reply! My application has a User management, Users with administrative rights can create accounts on the website. My problem was only, to create the very first account for the first Admin. For this I wanted to use IIS. But I've solved it very similar like you describe: Setting the app pool temporarily to .NET 2.0. I remember that I also had to disable the targetframework attribute (4.0) in web.config temporarily in order to get this working. So it's OK for now. I hope (and guess) that user/role management of a .NET 4.0 application will be supported in the next version of IIS.
  • Carlos Aguilar Mares
    Carlos Aguilar Mares about 14 years
    That is somethign we are definitely looking into.