I'm currently developing an ASP.NET MVC3 application in VS2010 and I'm having some troubles with @Url.Action helper. I have an ajax request where I use this helper:
var url = '@Url.Action("Action", "Controler", new { a = "a", b = "b" })';
$.post(url).success(function(data) {
...
});
The problem is that the value of url after this is /Controller/Action?a=a&b=b, note the & between the route values. This isn't working, but if I do:
var url = '@Url.Action("Action", "Controler", new { a = "a", b = "b" })'.replace('amp;', '');
it works perfectly!!!
My action is something like this:
public JsonResult Action(string a, string b)
{
...
}
I have debugged my app and the action gets called and even a is "a", but b is null.
Is this the desired behavior of Url.Action? I don't think so. Please help me, what am I doing wrong? Should I add another parameter to my Url.Action call? Thanks in advance.