I got a solution with main page (Default.aspx) at this location "D:\Websites\wwwFlofab\HomeSite\Default\Pages" that is using a master page (Site.Master) at this location "D:\Websites\wwwFlofab\HomeSite\Master\Pages".
When accessing our website we were using a Default.aspx (not the one mentioned above) to redirect to my Default.aspx. That way, when I was typing our url, it was redirecting so instead of getting "http://www.mywebsite.com" I was having something like "http://www.mywebsite.com/HomeSite/Default/Pages/Default.aspx"
I didn’t liked the "/HomeSite/Default/Pages/Default.aspx" to be shown at first loading so I changed my IIS 7.5 default document to "Default/Pages/Default.aspx" to avoid a redirect.
It’s now correctly displayed on first load (http://www.mywebsite.com).
Then I saw something that I do not understand and that’s why I’m posting here 🙂
In my master page, I was having many images that were displayed like this
<img src='~/Styles/images/ASME.png' />
After that IIS default document changed, all these images (in master page) were not showing up (on first load only). To display them correctly, I need to add our url.
<img src='http://www.mywebsite.com/HomeSite/Styles/images/ASME.png' />
Why would my images display correctly on a manual redirect and not when it’s called from IIS?
It’s the same page, same folders, only the url changed.
You used the “~” sign in your image path but didn’t add
runat="server"so the path was sent as is to the client.The client took your image path and combined it with the url of the page address, so
"http://www.mywebsite.com/HomeSite/Default/Pages/Default.aspx"and'~/Styles/images/ASME.png'resolved in"http://www.mywebsite.com/HomeSite/Styles/images/ASME.png", but when the address is only the host name, then the image url will result in"http://www.mywebsite.com/Styles/images/ASME.png".The way to solve it is to add
runat="server"to the image, so the server will resolve the correct client url in any case.