Ahmad
Ahmad

Reputation: 12737

How can I configure IIS to host app and not break relative paths?

I have developed an ASP .Net application (.net framework 4.7).

The app runs without any issues in Visual Studio, and when hosted on Server 2019 (IIS 10)

Now I need to host a different app on the same server. So I created two folders app1 and app2 on the main site, then right-clicked each and selected Convert to Application. Both were converted and I am now able to point my browser to http://server/app1 and http://server/app2 and each application loads.

The only issue is all images, master pages, javascript, css, etc, are all broken since they are being expected to be relative to the main site, and not nested in a sub-path.

What can I do to let IIS resolve all paths in app1 relative to app1 folder, without me having to specify it (hardcode the virtual path)?

Upvotes: 0

Views: 74

Answers (1)

Jason Pan
Jason Pan

Reputation: 22039

I follow your description and create 2 brand new projects and can't reproduce the issue. Then I double check the css files and javascript files. It works normally.

Then I think the files can't be loaded should be write by yourself. Could please check it like below, I think the APP2/Content/css?v=xxxxxx could be loaded normally.

enter image description here

So my suggestion is

using relative path to load those static files.

Upvotes: 0

Related Questions