Reputation: 1857
i have one problem arrive in my application actually my application is has some functionality like as searching...etc When you search with like computer keyword then url is like as below
http://www.example.com/Computer-Company/computer/1
Here computer is keyword But Company is my controller name so i write down some code in my RouteConfig.cs file the code is
routes.MapRoute(
name: "SearchResult",
url: "{Name}-{controller}/{TagName}/{page}",
defaults: new { controller = "Company", action = "Index", TagName="",Name="",page=""}
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
and i have also header and header contain some links like as Home when i hover on the home link at that time my url is below
so please how can i solve it.
Upvotes: 1
Views: 130
Reputation: 428
If you use page parameter with *, you can send to action.
routes.MapRoute(
"SearchResult",
"Company/{*page}",
new { controller = "Company", action = "Index" }
);
Upvotes: 1