I have an ASP.NET MVC3 application published at the url:
http://servername.com/Applications/ApplicationName/
In my code, I use jquery ajax queries as follows:
$.get(('a/b/c'), function (data) {}, "json");
When I run the application locally, the ajax request goes directly to the correct page (which is mvc traffic), because the local page ends with the "/" ( localhost/a/b/c) character .
However, when I publish to http://servername.com/Applications/ApplicationName/, the final "/" is not always present. The URL may be http://servername.com/Applications/ApplicationName, after which the ajax request tries to load http://servername.com/Applications/ApplicationNamea/b/c, which for obvious reasons is not executed.
I already looked at rewriting url to add a trailing slash, but A) That didn't work, and B) I feel this is a bad solution to the problem, and that it would be better to set javascript urls to work correctly regardless of setting the local folder.
I tried "../a/b/c" and "/ a / b / c", but none of them worked.
Thanks in advance for your help!
source
share