简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM