0

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?

2
  • It should. Can you add your RouteCollection content? Commented Aug 21, 2013 at 20:19
  • My Route collection is the default one Commented Aug 21, 2013 at 20:27

1 Answer 1

1

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 }
                    );
Sign up to request clarification or add additional context in comments.

1 Comment

be sure to add this before your Default Route, the order of declaring routes matters

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.