To perform a login using the FormsAuthentication module, you may want to just use the RedirectFromLoginPage static method, which, under the covers:
- prepares the authentication token;
- encrypts it;
- adds it to the cookie collection of the response;
- performs the redirect to the required page (or the default one, as per your web.config).
Here is a short prototype for your handler:
public void ProcessRequest(HttpContext context)
{
// TODO: Determine the user identity
var username = context.Request.QueryString["username"];
FormsAuthentication.RedirectFromLoginPage(username, true);
}
If you are not comfortable by the way this method performs its job, you may do each activity in a manual way:
- prepare a FormsAuthenticationTicket with the user name;
- encrypt it by way of the Encrypt method;
- add it to the response Cookies;
- issue a redirect.