Frage

I'm quite the novice with IIS, and am trying to setup two applications in one website. This is what I have done:

I have created a website in IIS, and have added two applications to the website. I can successfully navigate to:

http://servername/site1
http://servername/site2

Each of my different applications show up, and everything appears to work fine. The issue is what the redirects in my C# code actually redirect to. I try to navigate to a different page like the following:

Reponse.Redirect("~/Folder/Page.aspx");

Instead of looking in the application folder (site1/Folder/Page.aspx), it is looking in the website root for the folder: http://servername/Folder/Page.aspx instead of 'http://servername/site1/Folder/Page.aspx. How do I get the '~' to refer to the Application root, and not the whole website root?

War es hilfreich?

Lösung

I think this may do the trick: Response.Redirect(HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + HttpContext.Current.Request.ApplicationPath + "/Folder/Page.aspx")

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top