我的 Global.asax.cs 中有这个:
routes.MapRoute("BetaAccess", "beta-access", new { controller = "Beta", action = "Index" });
这在我的 Controller 中(HomeController 上的索引操作),它肯定会受到攻击:
RedirectToRoute("BetaAccess");
但仍然没有发生重定向...它只是转到正常的主页。难道是我用错了?
此外,我可以执行 Response.Redirect("~/beta-access") 并且它会转到测试版页面...
最佳答案
RedirectToRoute 返回 RedirectToRouteResult。试试这个。
return RedirectToRoute("BetaAccess");
关于asp.net - RedirectToRoute 应该如何使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1290355/