Question

I'm using FormsAuthentication (with cookies) for users authentication, with the default cookie name (".ASPXAUTH").

What I need is a different login system for the "/Admin/" virtual directory (backed by an ASP.NET MVC controller, "AdminController")... as if the "/Admin/" directory was another web application, but without creating another web project inside my solution.

How can I customize, at runtime, the cookie name used by FormsAuthentication? The FormsAuthentication.FormsCookieName is readonly (and static...), and can be customized only once inside the web.config...

Should I create a custom FormsAuthenticationModule?

A controller filter, like the following, could be great:

[CustomFormsAuthenticationCookie("NewCookieName")]
public class AdminController : Controller
{
Was it helpful?

Solution

Trick is the underlying authentication framework really can't handle this--you can't have multiple forms authentication bits running. Easiest solution would be to break the admin bits off into a separate website which would end up living elsewhere and not get caught up in the public site's authentication.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top