Reputation: 68810
I have a link created like this:
Html.ActionLink("Holdings", "Index", "Holdings", new { id = greenbaby }, null)
it renders a link:
http://blah/Holdings/Index/greenbaby
I need
http://blah/Holdings/Index/?id=greenbaby
or
http://blah/Holdings/?id=greenbaby
Is there a way to get the ActionLink to do that?
Upvotes: 0
Views: 1372
Reputation: 3479
You may add special route for it:
//*returns blah/Holdings/?id=greenbaby
routes.MapRoute(
name: "MyRoute",
url: "blah/{controller}/?id={id}",
defaults: new { controller = "Holdings", action = "Index", id = UrlParameter.Optional }
);
//*returns blah/Holdings/Index/?id=greenbaby
routes.MapRoute(
name: "MyRoute",
url: "blah/{controller}/{action}/?id={id}",
defaults: new { controller = "Holdings", action = "Index", id = UrlParameter.Optional }
);
Upvotes: 1