开发者

how to identify rootpath for application server?

开发者 https://www.devze.com 2023-04-05 19:14 出处:网络
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

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") %>
0

精彩评论

暂无评论...
验证码 换一张
取 消