In my view I'm using a
<img src="@Url.Action("Method", new { Model.Url })" ...
<img src="@Url.Action("Method", new { Model.Url })/1" ...
And in that method I have params:
public ActionResult Method(string url, int ids=0)
With
var book = GetBookByUrl(url);
...
switch (ids)
{
case 1:
In my global.asax I have:
routes.MapRoute(null,
"{controller}/{action}/{url}/{ids}",
new { controller = "Controller", action = "Method", url = "", ids = @"\d+" });
My view returns the correct URL's (with /1 and /2 appended), but I can't seem to get my method to retrieve the value of ids so that I can manipulate them in my action method to retrieve different results based on the Url.Action URL provided within my view, what gives?
The ids parameter seems to always be 0 (not being routed data) and the url parameter has the entire url "bla-bla/2", which I do not want.
Please note that although there are plenty of routing resources, I've read over them and can't seem to get this to work - also is this the standard way of routing data from a request to a controller?
Please show me by way of example how to solve, many thanks!