【问题标题】:Redirection with routes in ASP.NET MVC 4在 ASP.NET MVC 4 中使用路由重定向
【发布时间】:2012-08-27 00:09:45
【问题描述】:

我正在为使用 .Net Framework 4.5 编写的应用创建重定向。

在 RouteConfig 文件中,我创建了一个新的routes.MapRoute(),它可以工作。 它显示了我想要的控制器和操作。

但我不想保留用户的 url 并从那里使用应用程序。 我只希望当用户编写 /Something 时,它会重定向到 /AnotherSomething,而不是在 /Something 中使用应用程序。

我该怎么办?

【问题讨论】:

标签: c# asp.net-mvc asp.net-mvc-4 asp.net-routing


【解决方案1】:

如果理解正确:

routes.RouteMap("RedirectExample", "Something", new { controller : "MyController", action : "AnotherSomething"});

【讨论】:

  • 我认为这向我展示了我想要但维护 URL 的应用程序。我希望当用户键入 /Something 时,它会重定向到 Something/Anothersomething。
猜你喜欢
  • 2014-06-16
  • 1970-01-01
  • 1970-01-01
  • 2017-10-04
  • 2015-06-22
  • 2019-07-30
  • 1970-01-01
  • 1970-01-01
  • 2010-09-19
相关资源
最近更新 更多