Hope it's easy. I have a pretty simple ASP.NET application (framework version 2) that uses a user table to validate a user. In any case, I have two pages, login and registration. You can guess what the goal is. It is assumed that the user can request registration by clicking on the registration link - this is a form with a submit button that calls some database calls to find out if the user exists, etc. The login page uses authentication to verify. I use forms authentication - this is in my web.config:
<authentication mode="Forms">
<forms loginUrl="logon.aspx" name="adAuthCookie" timeout="30" path="/" defaultUrl="~/logon.aspx">
</forms>
</authentication>
Each time I make an http call on the registration page (i.e. by typing http: //localhost/registration.aspx - it is redirected to the login page.
In the global.asax.cs file there is this - authentication. I want to disable this check if the requesting page is a registration page, since users do not need to authenticate to visit this page. Any ideas how to do this?
void Application_AuthenticateRequest(object sender, EventArgs e)
{
string cookieName = FormsAuthentication.FormsCookieName;
HttpCookie authCookie = Context.Request.Cookies[cookieName];
if (null == authCookie)
{
return;
}
FormsAuthenticationTicket authTicket = null;
try
{
authTicket = FormsAuthentication.Decrypt(authCookie.Value);
}
catch (Exception ex)
{
return;
}
if (null == authTicket)
{
return;
}
string[] groups = authTicket.UserData.Split(new char[] { '|' });
GenericIdentity id = new GenericIdentity(authTicket.Name, "LdapAuthentication");
GenericPrincipal principal = new GenericPrincipal(id, groups);
Context.User = principal;
}
source
share