Cookie authentication

Want to turn on the ASP.NET "Remember me next time"-functionality when the user authenticates? In our demos this is not enabled by default, to enable this you must do the following.

First of all you have to add the following code to your login code-behind (typically called "Login.aspx.cs"):

protected void Page_Load(object sender, EventArgs e)
{
if (User.Identity.IsAuthenticated)
Response.Redirect(String.IsNullOrEmpty(Request.QueryString["ReturnUrl"])
? "/Demo1/Default.aspx"
: HttpUtility.UrlDecode(Request.QueryString["ReturnUrl"]));
}

You also have to turn on cookies in your web.config file, typically something like this:

<authentication mode="Forms">

<forms loginUrl="WAF/View/Login.aspx" protection="All" cookieless="UseCookies" timeout="525600" />

</authentication>