ASP. NET MVC Cookie Timeout returns login page issue

Source: Internet
Author: User

FilterContext.HttpContext.Response.Write ("<script>top.location.href = '/login/index ';</script>");

When using the time-out setting, you can return to the login page during native debugging, but not to the login page after the server deployment, the previous code is as follows:

public class Handlerloginattribute:authorizeattribute
{
public bool Ignore = true;
Public Handlerloginattribute (BOOL ignore = TRUE)
{
Ignore = Ignore;
}
public override void Onauthorization (AuthorizationContext filtercontext)
{
if (Ignore = = False)
{
Return
}
if (OperatorProvider.Provider.GetCurrent () = = null)
{
Webhelper.writecookie ("Schemedesign_login_error", "overdue");
FilterContext.HttpContext.Response.Write ("<script>top.location.href = '/login/index ';</script>");

Return
}
}
}

Puzzled for a long time, later saw the code of others on the internet somewhat different, replaced this code:

FilterContext.HttpContext.Response.Write ("<script>top.location.href = '/login/index ';</script>");

Replace with the following:

FilterContext.HttpContext.Response.Redirect ("/login/index");

After the test is feasible, the problem is solved, but do not know what is the reason, the first one did not succeed. Personal speculation is the cause of the environment, so after the use of the latter, can be executed jump.

ASP. NET MVC Cookie Timeout returns login page issue

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.