Urls on nested web application under IIS Web Site
I have website running under IIS 7.5. It has child web application 'WebA'. Path to that site is 'localhost/weba' WebA has some pages with anchors on it, anchor urls are like '/UserDetails.aspx'. When I click on this anchors, browser redirects me to localhost/userDetails.aspx instead of localhost/weba/userdetails.aspx.
I have working example under IIS 6, but have no idea what option should be set to make it work under IIS 7.5
You should try
<asp:HyperLink NavigateUrl="~/UserDetails.aspx" runat="server">My link</asp:HyperLink>
and it should redirect to localhost/weba/userdetails.aspx.
In Javascript you can use the value of
var myUrl = '<%= System.Web.VirtualPathUtility.ToAbsolute("~/UserDetails.aspx") %>';
Basically you need to add a '~/' to the beginning of your path because it's the application relative path and not the path of the root domain.
链接地址: http://www.djcxy.com/p/61196.html