39

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...

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
Max Schmeling
  • 12,363
  • 14
  • 66
  • 109

2 Answers2

46

RedirectToRoute returns a RedirectToRouteResult. Try this instead.

return RedirectToRoute("BetaAccess");
Joel
  • 19,175
  • 2
  • 63
  • 83
4

This will redirect you.

Response.RedirectToRoute("BetaAccess");
Response.End();
Michael
  • 41
  • 1
  • I am having trouble with that too.... i am using it in webForms but i get this error : "A route named 'Students/Basic-Information' could not be found in the route collection. Parameter name: name" ... i have defined the route like : " Routes.MapPageRoute("StudentsBasicData", "Students/Basic-Information", "~/Student/BasicInfo/BasicInfoCompletion.aspx");" – Lucky May 18 '13 at 08:05