asp.net - RedirectToRoute 应该如何使用?

标签 asp.net asp.net-mvc routes redirecttoroute

我的 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/

相关文章:

asp.net-mvc - 我发布的时候,Web.Release.config中connectionStrings的内容没有被复制

listview - React Native动态ListView主细节

windows - "bind: An attempt was made to access a socket in a way forbidden by its access permissions"

asp.net - 对象未被垃圾回收,但不包含 gcroot

c# - 如何在 MVC 中检查用户是否经过身份验证

c# - 构建 C# Web API - REST

c# - 使用获取的 Json 数据返回 Ajax 成功调用中的部分 View

c# - 为什么 MVC 不绑定(bind)我的嵌套集合?

scala - Play Framework 2.1 中的 AbsoluteURI 支持

asp.net - 在 asp :Panel? 中隐藏 DIV