I want to pass multiple values to a controller. The controller looks like
Page(string type, string keywords, string sortType)
In a asp.net page,
I have
<%=Url.Action("Page", "Search", new { type = "new",keywords = keywords, sortType = "Date" }) %>
But the values for type and sorType are passed as null inside the controller.
What am I doing wrong here?
I’ve just double-checked, and this should work fine. I created this controller method in a new MVC app’s Home controller:
and then added this to the Index view:
The page correctly displays the following after clicking the “Hello” link:
So if this works in a simple new MVC app, I think it must be either other methods in your controller or a routing problem causing it.