I have a C# website which works fine in IIS6 & IIS7 on a company intranet but am now attempting to install the same website on a Windows XP box with IIS5 for a different part of the company intranet. The website content is fine but the css and menus are all broken, as some of the relative paths can’t be found.
I am using some notation like this: <img src="Images/a.gif" which works fine, and some like this: MasterPageFile="~/App_MasterPages/Default.master" which also works fine, but the stuff like this: @import "/App_Themes/Default.css" and this: src="../App_Scripts/stringformat.js" is no good. In the code-behind Request.ApplicationPath is also missing the “/” off the end.
I tried unticking the “Enable Parent Path” in IIS and did an iisreset but it made no difference. I also tried installing IIS Developer Express, but that was confusing and sucked too much. I don’t want to have to go through the whole application and change every relative path just to support IIS5 format, but is that my only option? (apart from upgrading Windows)
I suspect that on IIS6 & 7 the application in question is being deployed into the site root and that on XP/IIS5.1 you’ve deployed this into a sub folder running as an IIS application.
You have two options:
Deploy the site into the IIS5.1 root (
c:\inetpub\wwwroot).Fix the absolute paths and make them application relative i.e.
@import /App_Themes.Persevere with IIS Developer Express, it’s not that sucky.