Resolving the localhost uri into a local path

  • Thread starter Thread starter MrPolite
  • Start date Start date
M

MrPolite

I want to figure out (by code) what directory http://localhost is pointing
to. I'm opening a VS.NET solution file with my program and trying to analyze
it... whenever there is a ASP.NET project, it's path always starts with
http://localhost in the solution file. So to figure out the path of the
project file on the machine I need to figure out where localhost points to
(ie, the project's path is "http://localhost/adminTools" and I want to
convert that to a local path.
Does anyone know of a way? I couldn't find any registry keys for this
either. I'm looking for the correct method, if there is any
 
Hi Mr Polite,

Localhost is IP 127.0.0.1 normaly in webpages on a .Net computer it points
to your virtual webserver adres which is as hard adres mostly
C:\Inetpub\wwwroot

I hope this helps?

Cor
 
Oh what a stupid answer !

After all, I believe that you should ask the specific command of your server
application. Because the multiplicity of ! Like Personal Web Server from
Microsoft, Apache, and others ... It's not possible to have that information
without having access rights to the server, and then that the reason why you
must to connect to the server with your access codes to have informations.

Bismark
 
well, again I'm opening a solution file, then from that solution file I'm
getting the path of the project file. Now I want to open the project file
with a streamReader. I can do it just fine with other projects, but it wont
work with an ASP.NET project
for example if the path is
http://localhost/WebApplication1/WebApplication1.vbproj
you cant open that path with an streamreader class

my program analyzes projects, and I want it to be able to analyze asp.net
projects as well. thats why I need to figure out the directory which
localhost points to. (I dont care about the default directory. some people
change the default directory for iis and I need to figure this out by code)

hope its clear
 
HKLM\System\CurrentControlSet\Services\W3SVC\Parameters\Virtual Roots, Name
= "/" - ??? - not sure, just a guess.

Mike
 
MrPolite said:
well, again I'm opening a solution file, then from that solution file I'm
getting the path of the project file. Now I want to open the project file

Try Server.MapPath

Charlie
 
Hey thanks for the response, that may be it.... but a quick question though:
I'm running this code from a win application and not an asp.net application.
I added the system.web reference. Now can you tell me which namespace I
should look in for Server.MapPath?
 
MrPolite said:
Hey thanks for the response, that may be it.... but a quick question though:
I'm running this code from a win application and not an asp.net application.

My mistake, I thought you were building an ASP.NET app. I know of no
way to do what you are asking other than browsing the registry. Even
knowing the physical location of the localhost webroot doesn't really
help as virtual directories can be located anywhere on the local
machine (or perhaps even off, I'm not really sure).

I would suggest you look into the underpinnings of IIS or whatever
your local server is.

Good Luck,
Charlie
 
Back
Top