c# - How to redirect user to another Url from MVC Custom Router Handler? -


i working custommvcrouterhandler, based on logic want redirect user url customhandler.

public class custommvcrouterhandler : iroutehandler {      public ihttphandler gethttphandler(requestcontext requestcontext)     {         if (requestcontext.httpcontext.request.isauthenticated)         {             if (logic true)             {                 string orginalurl = "/home/aboutus";                 // redirect url = "/home/companyprofile";                 return new mvchandler(requestcontext);             }          }          return new mvchandler(requestcontext);     } } 

how redirect user "home/companyprofile" customrouterhandler ?

you can use underlying asp.net response object redirect user url.

requestcontext.response.redirect("/home/companyprofile"); requestcontext.response.end(); 

it send redirect response browser , end http request processing.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -