Last post Nov 18, 2009 04:22 AM by imran_ku07
Nov 11, 2009 11:48 AM|FruitBatInShades|LINK
In my visual studio project I have my virtual path set to '/' so it appears to the browser that the site is NOT running in a folder.
http://localhost:333333/ even though it lives in c:\websites\my project folder\
When I move it to IIS to a sub directory c:\websites\my project folder\ the url shows up as http://server1/my project folder/ so img links are not working. The links are in the html so I can not use "~/" as you can with the img control.
Is it possible (and how) to get a virtual directory in IIS to report the same style of url as when running in Visual Studio with Virtual Path set to '/'?
If not, any ideas how this can be dealt with without doing a replace on the content!
Nov 11, 2009 12:21 PM|sanjeev87|LINK
just go through the post
there i have mentioned how to create a virtual directory.just follow the steps
Nov 11, 2009 12:27 PM|FruitBatInShades|LINK
A virtual directory still appears in the url. If I've populated the site on VS with virtual path set to '/' the img paths are
But when running under a virtual directory this is incorrect as the image now lives under the path
Nov 11, 2009 12:50 PM|sanjeev87|LINK
well if you have created the virtual directory through the steps i have mentioned then i think you should not face any problem.
actually the mapping goes on internally and it has nothing to do with the image source.i.e. the path should remain same.(if your project ran perfectly before deploying to iis)
please follow the steps to create the virtual directory and browse the project directory.
i think you will not face any problem.
Nov 13, 2009 10:39 AM|FruitBatInShades|LINK
Hi sanjeev, that post does not describe my problem but I went though all the steps anyway and my issue is not resolved.
The problem I have is that '/' maps to /localhost/projectname/ so when the urls on the page start with /images/ they relate to /localhost/images/ not /localhost/projectname/images/. In VS you can override this behavior by setting the virtual path to '/'
Nov 17, 2009 01:17 AM|sanjeev87|LINK
i am ignorant about the fact.
well please post this in iis.net.
The experts there can help you.
Nov 18, 2009 04:22 AM|imran_ku07|LINK
Use ../ , for example
<img src="Images/Icon_changepw.jpg" id="img1"/>
<img src="../Images/Icon_changepw.jpg" id="img1"/>
document.getElementById("img1").src = "http://"+location.host+'<%=Request.ApplicationPath %>'+"/Icon_changepw.jpg";