AJAX url routing issue in IIS with virtual directory AJAX url routing issue in IIS with virtual directory ajax ajax

AJAX url routing issue in IIS with virtual directory


You can add some code to your layout file or master page that writes out the root directory to a JS variable before including the JS file. Then you can use that variable to build the path in your JS file.

In Razor:

<script type="text/javascript">    var rootDir = "@Url.Content("~/")";</script><script src="@Url.Content("~/Scripts/MyScript.js")" type="text/javascript"></script>

Then you can just build your url in your file like this:

var myurl = rootDir + "Home/Save/";