I am looking to create a virtual directory to host a demo of an application. the app is written in asp.net mvc and the images/css etc point to /Content/images /Content/main.css etc.

when the app is in the main directory everything is fine. when i create a virtual directory (say www.app.com/admin) then the images and css point to www.app.com/Content/images etc.

Is there any way to make the resources be relative to the virtual directory? thx

My host uses dotnetpanel


Remove the first slash from the path. The first slash make it an absolute path.

Update to comment: From the point of view of the app user the current directory is: www.app.com/admin
so the path: "Content/main.css" will be added to it and the result will be:
Which is the path you want.

Try it.

Update 2: The url is not relative to where we are "looking" but to the place it is declared from. So if you have to get from:
the path should be: ../../admin/Content/main.css

  • but then it will be relative to the current folder. if i am looking at home/action and i select profile/user it will go to home/action/profile/user – Yannis Oct 30 '09 at 18:54
  • will give it a try and lets hope its that simple – Yannis Oct 31 '09 at 11:51
  • as expected it doesnt work. if the css is linked to Content/css/main.css then this is relative to the current "directory". if we are looking at www...com/categories/new then the css is relative to that – Yannis Oct 31 '09 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy