Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running Visual Studio under localhost

Status
Not open for further replies.

JCruz063

Programmer
Feb 21, 2003
716
0
0
US
Hello all...

The Setting
I recently upgraded to Visual Studio 2005 (from 2002). At the same time, I started working on a ASP.NET website developed by someone else. The website was designed so that path references start with the root (\), so when referencing an image, the path looks like this \some foler\images\image.jpg. I have the website installed on the root folder of IIS (inetpub) on my Windows 2000 machine. I can run the application/website by typing " on IE.

The Problem
For debuggin purposes, I want to run my application using Visual Studio (duh). Thus, I open the application and hit F5. When I do this, though, the website runs uder and this causes the paths I mentioned above not to work. I can easily fix this by removing the initial backslash (\) from all the paths. However, if I do this, certain paths won't work. For example, I have a master page that is used for some pages on two different folders: \folder1, and also \folder1\subFolder1. For pages located at \folder1, everything is fine, but for pages at \folder1\subFolder1, paths on the master page will be incorrect as they would be relative to \folder1 which is where the master page is located. I hope I'm making myself clear.

So the question is, how can I have Visual Studio run under as opposed to so that everything works as epected? Or better yet, am I approaching this the right way? How should this be accomplished?

Thanks

_________________________________
I think, therefore I am. [Rene Descartes]
 
1.) Use relative paths for your images

2.) You will have to move your project to to run it under localhost. The website was created with the File System Location option instead of the HTTP option. To fix this, the easiest way would be to copy the files to a temp dir, then delete the website and recreate it using the HTTP Location option.
 
Thanks jbenson...

1) I could see why relative paths were not used for this website. Using relative paths, the links on a master page that sits on "\foler1" and is used by a page on "\folder1\subFolder1" will not work. I have several subfolders and I have a single masterpage (which sits on the top folder) which is used for pages in the subfolders. Thus, I'm afraid I cannot use relative paths, unless I create one master page for every subfolder (and I would like to avoid that). Am I mistaken? Perhaps I'm missing something.

2) My website is currently sitting at C:\Inetpub\FolderForMyWebsite. I don't have on my machine. What I have is inetpub\ Is this what you mean? I'm not familiar with the File System vs HTTP options - I'll check this out.

Thanks again.

_________________________________
I think, therefore I am. [Rene Descartes]
 
Thus, I'm afraid I cannot use relative paths, unless I create one master page for every subfolder (and I would like to avoid that). Am I mistaken? Perhaps I'm missing something
You can use a tilde sign (~) to specify the root folder. e.g.
Code:
<img id="imgLogo" runat="server" src="~/images/Logo.gif" alt="My Logo/>


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
To see what I mean about file system vs HTTP, go to File-->New WebSite. On the bottom there are options for your site. One is the Location dropdown. There you will see the options I am talking about.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top