I got a .NET MVC3 project which was just deployed to an actual server inside a virtual directory. Let's call it VirtDir. My JavaScript files all had URLs for AJAX defined like this:

"/Home/Save/"

which was working fine locally.

On the actual server, that first "/" kills the virtual directory, so I get

"/Home/Save/" instead of "/VirtDir/Home/Save/" which obviously fails.

If I remove the first "/", then things break locally, resulting in defined URL being appended to the URL of the current page: If you're on "/Home/Index" page, the AJAX URL would point to

"/Home/Index/Home/Save".

My JavaScript is in separate *.js files, so I can't really write @Url.Content to them.

Anyone knows of a good solution for this problem?

Edit
Report