I had a problem sending a string back as a routeValues parameter from an MVC ActionLink if I have BOTH of the conditions below:
- The parameter name is "id"
- The data contains a full stop, e.g. mystring.bad
I have see this question and this question which refer to a problem with using "id" but they don't seem to cover the case above.
Below I have listed different ActionLinks with the urls they produce listed below each one: the first two work, the last two fail.
@*Links that work*@
@Html.ActionLink("Test OK", "About", new { id = "mystring" }, new { @class = "k-button" })
@*Above produces url http://localhost:55745/Home/About/mystring*@
@Html.ActionLink("Test OK", "About", new { stringId = "mystring.bad" }, new { @class = "k-button" })
@*Above produces url http://localhost:55745/Home/About/mystring?stringId=mystring.bad*@
@*Links that FAIL*@
@Html.ActionLink("FAIL: 4 param ActionLink", "About", new { id = "mystring.bad" }, new { @class = "k-button" })
@*Above produces url http://localhost:55745/Home/About/mystring.bad*@
@Html.ActionLink("FAIL: 5 param ActionLink", "About", "Home", new { id = "mystring.bad" }, new { @class = "k-button" })
@*Above produces url http://localhost:55745/Home/About/mystring.bad*@
The last two that fail produce the following error: "HTTP Error 404.0 - Not Found".
Anyone got an idea on how to fix this? I can of course change the parameter name to something other than "id" but I would like to know why this does not work.
Notes:
- The three parameter, i.e. without the HtmlAttributes, also fails in the same way.
- My route table is just the default MVC setup.