[英]How to return ActionResult with specific View (not the controller name)
[英]how to route url having QueryString to specific ActionResult of Controller
我正在C#中使用ASP.NET MVC 3,并且要将由QueryString
组成的URL路由到所需的控制器和操作方法。 URL将类似于localhost:44578/HVAC/?pos=installer
我要对此进行路由。 我不知道该怎么做。 我是MVC的新手。
RouteConfig中的默认路由为
routes.MapRoute(
name: "Default",
url: "{siteName}/{controller}/{action}/{id}",
defaults: new { controller = "SeoTree",
action = "Index", id = UrlParameter.Optional }
);
我想创建一个新的Map路线,将url路由到Contoller = "SeoTree" ,action ="PositionInAll"
只需根据需要映射路线即可:
routes.MapRoute("Custom",
"{controller}/{action}/{pos}",
new { controller = "seoTree", action = "PositionInAll"},
new { pos = @"\d+" }
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.