I am working on ASP.NET MVC 3 in C# and I want to route the URL consisting of QueryString
to desired controller and action Method. URL will be like localhost:44578/HVAC/?pos=installer
I want to route this. I don't know how to do that. I am new to MVC.
default route in RouteConfig is
routes.MapRoute(
name: "Default",
url: "{siteName}/{controller}/{action}/{id}",
defaults: new { controller = "SeoTree",
action = "Index", id = UrlParameter.Optional }
);
I want to create new Map route which routes the url to Contoller = "SeoTree" ,action ="PositionInAll"
just map the route as you wanted like:
routes.MapRoute("Custom",
"{controller}/{action}/{pos}",
new { controller = "seoTree", action = "PositionInAll"},
new { pos = @"\d+" }
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.