2015-06-16 186 views
0

在获取操作方法,我返回查看和传递模型。如何隐藏网址中的模型细节? ASP.NET MVC

return View("MyView", model); 

然后我得到所需的查看模型详细信息在URL中。

host:/response?id=1&otherId=2 ... 

我想有下一个网址:

host:/response 

如何获得呢?或者如何按照我想要的方式来映射路线?

回答

1

在您的解决方案资源管理器中,转至App_Start文件夹。在该文件夹中打开RouteConfig.cs文件。打开它。 你会显示类似

routes.MapRoute(
       name: "Default", 
       url: "{controller}/{action}/{id}", 
       defaults: new { controller = "Shared", action = "WelcomeView", id = UrlParameter.Optional } 

变化url:的东西,只要你想展示。如果您不想在您的网址中看到id,我建议您制作一个新的MapRoute,并且不要在其中包含id