I have this in my Global.asax.cs:
routes.MapRoute("BetaAccess", "beta-access", new { controller = "Beta", action = "Index" });
And this in my controller (index action on HomeController) and it definitely is getting hit:
RedirectToRoute("BetaAccess");
But still no redirection happens... it just goes to the normal home page. Am I using it wrong?
Also, I can do Response.Redirect("~/beta-access") and it goes to the beta page...
RedirectToAction will return a http 302 response to the browser and then browser will make GET request to specified action. Show activity on this post. Ideally I would use RedirectToRoute for Action Links/Images and RedirectToAction in Controller's Action to redirect to another Controller's Action .
RedirectToRoute(Object) Redirects to the specified route using the specified route values. RedirectToRoute(String) Redirects to the specified route using the route name.
Response. Redirect sends an HTTP request to the browser, then the browser sends that request to the web server, then the web server delivers a response to the web browser. For example, suppose you are on the web page "UserRegister. aspx" page and it has a button that redirects you to the "UserDetail.
RedirectToAction(String, Object) Redirects to the specified action using the action name and route values. RedirectToAction(String, String) Redirects to the specified action using the action name and controller name.
RedirectToRoute returns a RedirectToRouteResult. Try this instead.
return RedirectToRoute("BetaAccess");
This will redirect you.
Response.RedirectToRoute("BetaAccess"); Response.End();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With