ASP.NET MVC resolve urls in javascript

后端 未结 4 1221
执笔经年
执笔经年 2020-12-25 08:11

I am loading up some content via jQuery.load(\'/Business/Tags\'), which works well when using my local webserver. But when using iis this does not resolve correctly. I hav

4条回答
  •  [愿得一人]
    2020-12-25 08:22

    A couple of ways we do this in our apps:

     var applicationPath = '<%= Url.Content("~/") %>';
    

    OR

     var applicationPath = '<%= Request.Url.Scheme %>://<%= Request.Url.Host %><%= Request.ApplicationPath %>/';
    

    We then use applicationPath as the base url for all our ajax calls.

提交回复
热议问题