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
Post a Comment