how to identify rootpath for application server?
In my .net web applica开发者_如何学编程tion I create a blank solution and add website and class library into it. All the website pages are in UI folder, so when I use
'<%=ResolveUrl("~") %>'
in javascript, it returns '/UI/', but in application server I set website root at UI folder, so '<%=ResolveUrl("~") %>' returns '/'. The problem here is, when I call AjaxPages under UI/AjaxPages/ folder it only works at local, it does not work at application server. The code I use is
var root='<%=ResolveUrl("~") %>';
$.post(root+"AjaxPages/UserStatus.aspx",....)...
Even I use
var path='<%=ResolveClientUrl("~/AjaxPages/UserStatus.aspx") %>';
$.post(path,....)
It still does not work in application server, but works local. I really have no idea what's wrong here. Thank you for any tips.
Try this:
var path = '<%# Page.ResolveClientUrl("~/AjaxPages/UserStatus.aspx") %>';
How about:
<%=Url.Content("~~/AjaxPages/UserStatus.aspx") %>
or:
<%= VirtualPathUtility.ToAbsolute("~/AjaxPages/UserStatus.aspx") %>
精彩评论