Asp.net mvc ASP.net MVC默认路由以显示实际路由

Asp.net mvc ASP.net MVC默认路由以显示实际路由,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-routing,Asp.net Mvc,Asp.net Mvc 3,Asp.net Mvc Routing,我有一个MVC 3应用程序,我的默认路径是app/index,这意味着如果用户点击“”, 他们真的看到了“” 但是,我想始终显示实际的路由,这意味着当用户点击时 “”中,我希望地址栏中的url显示为“”。如何实现这一点?您可以在操作中使用重定向,如下所示: public class HomeController : Controller { public ActionResult Index(){ return RedirectToAction("Index","App");

我有一个MVC 3应用程序,我的默认路径是app/index,这意味着如果用户点击“”, 他们真的看到了“”

但是,我想始终显示实际的路由,这意味着当用户点击时
“”中,我希望地址栏中的url显示为“”。如何实现这一点?

您可以在操作中使用重定向,如下所示:

public class HomeController : Controller
{
   public ActionResult Index(){
     return RedirectToAction("Index","App");
     // or you can do a redirect to a URL. like 301.
     return RedirectPermanent("/app");
   }

}

那么您可能应该使用别名而不是路由<代码>url:“是指向
url:“app/”
的重定向。