I have a problem with routing in an existing ASP.NET application for work. I have the code for the application and i can build and run it. When i run it I see the home page, but all links and images have invalid URL's. For each URL the same problem occurs.

For example an image on the home page has this src: src="/appName/Images/img.jpg". but the image is actually at "/Images/img.jpg". Notice the missing '/appName', this is the problem with every link / image.

The root folder of the application is in the folder '/appName', but the URL's/images seem to think it is one folder above that.

Now I could change every URL and take out the '/appName', but I feel like it should be possible to run the website correctly without changing the code. Maybe i should change something about the environment or IIS express.

HttpContext.Current.Server.MapPath("~") returns the path to the /appName folder. So the img src and a href start looking in /appName/appName which doesn't exist.

I have searched online, but cannot find anything. I've already tried changing the root URL in applicationhost.config, but this resulted in IIS not finding an application in that folder.

I know the website works in the production environment, though i currently have no access to the production environment. But i do think it is an environmental setting (maybe in IIS).

So does anybody have an idea how to change it so the links think the root URL is one folder above the actual root folder in IIS?

0 Answers