Possible to use different forms authentication cookie names for multiple virtual directories mapped to one physical directory?
Using ASP.NET 2.0, IIS 7.
I have an ASP.NET application using forms authentication setup as follows in web.config :
<authentication mode="Forms">
<forms name=".ASPXAUTH_LIVE" loginUrl="Login.aspx" defaultUrl="~/Default.aspx" protection="All" timeout="1440" path="/" requireSSL="true" slidingExpiration="true" cookieless="UseDeviceProfile"/>
</authentication>
There are two IIS virtual directories mapped to the one physical directory. Since they map to the same physical directory, they b开发者_C百科oth use the cookieName : ".ASPXAUTH_LIVE". Is there some way to get the two virtual directories to use different cookie names ? I know I could make multiple copies of the physical directory, and change the name attribute in the web.config, but I'd rather not have to maintain multiple physical directories.
I cannot guarantee this will be of any assistance, but my first instinct would be to override the defaults for each virtual directory by adding a <location>
element to your site's root web.config:
<location path="Path/To/Virtual/Directory">
<system.web>
<authentication>
<forms name=".ASPXAUTH_LIVE2" />
</authentication>
</system.web>
</location>
At first blush I expect this to fail miserably, but if nothing else it's an idea to test. I apologize for not trying the configuration myself but this would require a bit of work on my part to configure a working test project.
精彩评论