Skip to content

Moving From Casini to IIS, Login Fails. How come?

Updated: at 11:17 PM

ASP.NET 2.0 Membership

A very common question that comes up while using ASP.NET 2.0 Membership is that when moving a web application from the local developer environment with Visual Studio 2005 (VS2005) to IIS is that login no longer works. Almost everytime this happens, it comes down to the application name in the Membership Profile of Web.Config is set to / instead of the actual application name. That is, if you you were to look at your web.config, this is what you would see.


<roleManager enabled=“true/>
     <membership>
          <providers>
          <remove name=“AspNetSqlMembershipProvider/>
          <add name=“AspNetSqlMembershipProvider
               type=“…“
               connectionStringName=“LocalSqlServer
               enablePasswordRetrieval=“false
               enablePasswordReset=“true
               requiresQuestionAndAnswer=“true
               applicationName=“/“
               requiresUniqueEmail=“false
               minRequiredPasswordLength=“1
               minRequiredNonalphanumericCharacters=“0
               passwordFormat=“Hashed
               maxInvalidPasswordAttempts=“5
               passwordAttemptWindow=“10p=“”
               asswordStrengthRegularExpression=“”/>
     </providers>
</membership>

Notice that the applicationName is set to just a "/". To make the application work with IIS, you really need to set that to the name of your application. That is, the correct way to specify applicationName is something more like this:

<roleManager enabled=“true/>
    <membership>
        <providers>
            <remove name=“AspNetSqlMembershipProvider/>
            <add name=“AspNetSqlMembershipProvider
                type=“…“
                connectionStringName=“LocalSqlServer
                enablePasswordRetrieval=“false
                enablePasswordReset=“true
                requiresQuestionAndAnswer=“true
                applicationName=“/MyCoolApp1
                requiresUniqueEmail=“false
                minRequiredPasswordLength=“1
                minRequiredNonalphanumericCharacters=“0
                passwordFormat=“Hashed
                maxInvalidPasswordAttempts=“5
                passwordAttemptWindow=“10p=“”
                asswordStrengthRegularExpression=“”/>
        </providers>
    </membership>

This also makes it so that you can share the same membership database across multiple applications.