R – Make ~/ reference the root folder (the same folder as web.config is in)

asp.netnetpathrelative-path

I'm working on a site in asp.net (my first) which is all going very well. That is until I deployed the app to our test environment, where the ~ (tilde) started referencing a folder parent to the root of my project.

On my computer the app lives in c:/Documents…/Visual Studio../WebSites/MyApp and ~ resolves correctly.

On the test server it lives in a subfolder to an existing site, so the url to the site (both while testing and once it goes live) is something like domain.com/oldexistingsite/myapp.

On the test server ~/ resolves to the root of domain.com which breaks the urls to my user controls registered in web.config and all other urls using the ~ operator to make relative urls.

Is there any way I can ensure that the ~ operator will resolve paths relative to the root of my app (i.e. the same folder where web.config file for my app is located)?

Sorry if this is something totally trivial – this is all new to me 😉

Best Answer

Sounds like you didn't make the subfolder an application in IIS; In IIS Manager on the server right click on the subfolder and hit properties, then create an application for the folder. Sorry, I don't have IIS installed on my home PC or I'd give you more complete instructions...

Related Topic