Search code examples
asp.netiisforms-authenticationvirtual-directory

Forms authentication ignored in virtual application


I have an admin site set up as a virtual applcation inside of another website.

I would like visitors to the sub directory (the virtual application) to be promtped for credentials using the same Forms authentication set up on the main parent site

Have tried all sorts of things but can't get it to work, including

Removing all <authentication mode="Forms">, <authorization>, <membership> and <roles> sections from the virtual-app web.config

Copying the same <authentication mode="Forms">, <authorization>, <membership> and <roles> sections from the parent to the virtual-app web.config

Using a virtual directory instead of virtual application

But I never get promted for credentials

Anyone know how to get this setup?

thanks

UPDATE:

Have now got it to inherit permissions from the parent, by deleting the application name in IIS (to make it a virtual directory rather than a virtual application)

However, this screws all the paths in the admin site

e.g. I get the following error

The file '/Site.master' does not exist.

So should I be using a virtual directory (which seems to inherit authentication from the parent)?

Or a virtual application (which currently doesn't inherit auth from the parent but has the correct relative paths)?

Here's the parent config

<membership defaultProvider="SqlServerMembershipProvider">
            <providers>
                <add connectionStringName="xxxxxxxx" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" name="SqlServerMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
            </providers>
        </membership>
        <roleManager enabled="true" defaultProvider="SqlServerRoleProvider">
            <providers>
                <add connectionStringName="xxxxxxx" applicationName="/" name="SqlServerRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
            </providers>
        </roleManager>

        <authentication mode="Forms">
            <forms name=".EPiServerLogin" loginUrl="login.aspx" timeout="120"/>
        </authentication>
        <authorization>
            <deny users="?"/>
        </authorization>

Solution

  • I needed to use a single sign on solution, as described here

    http://www.codeproject.com/KB/aspnet/SingleSignon.aspx

    The main point being, each site needs to use the same encryption key for the cookie values. So this machineKey element needs to be added to each site involved in the Single Sign On