How to stop running to the back code in the ASP.net MVC interceptor!__.net

Source: Internet
Author: User
 public override void OnActionExecuting (ActionExecutingContext filtercontext) {//This One step is to verify whether to log in if (filtercontext.httpcontext.session["User"] = = NULL) {//When using this method, the page
                The output will also run to the following code, using return is not effective;
                FilterContext.HttpContext.Response.Redirect ("~/home/index", true);


                return;
             
                
            Errorredirect (Filtercontext); }
        
Error handling method
private void Errorredirect (ActionExecutingContext filtercontext)
{
//Note: by In the front page of the IFRAME frame, use the following method to jump to the iframe inside, so can not be annotated with the method
//Filtercontext.result = new Redirecttorouteresult ("D           Efault ", new RouteValueDictionary (New {controller =" Home ", action =" Index "}));
Filtercontext.result = new Redirectresult ("/home/index");
Contentresult content = new Contentresult ();
Content.            Content = "<script language= ' javascript ' > top.location.href = '/home/index ';</script>";
Filtercontext.result = content;
}//End Errorredirect




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.