문제

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
{
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top