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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Server Root

Status
Not open for further replies.

DonP

IS-IT--Management
Jul 20, 2000
684
US
I know how to get the system path objects, but not the directory. Is there a way to get it? How is it used?

Don
don@ctagroup.org
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)
 
Use the ServerVariables collection.

I think APPL_PHYSICAL_PATH is the variable you want. That will return the actual path to the current 'web application' that you are on.

Incase you're not sure on how to call the value ...

Request.ServerVariables("APPL_PHYSICAL_PATH")

I hope this helps ... Ed (RoadRacer) Holguin

"I Hate Computers!"
 
Thanks Ed, but actually I don't want the path I'm in, I want the server root - that is, the base directory in which all the other files and folders for the site are stored. Is there a way to get it? I have pages that I load manually from one system to another (from my IIS PC to the Web server) and am trying to find a way to not have to remember to manually change the path each time.

Don
don@ctagroup.org
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)
 
Ah, you want to be able to move a page from one server to another and have its links reflect automatically?

If I understood you correctly, you have to join the server name with the path ... kinda like this ...

strLink = " & Request.ServerVariables("SERVER_NAME") & "/" &_
Request.ServerVariables("PATH_INFO")

The above example would create For example, if my server is named ROADRACER and the page I'm viewing happens to be in the RACING directory by the name of DAYTONA.ASP the above would result in this...


All you'd have to do is write a quick little function that would go through the above string and replace the current page's name (daytona.asp) with whatever page you're going to link to. A replace function jumps to mind and would work great.

I hope this helps ... I'll be monitoring for a response. Ed (RoadRacer) Holguin

"I Hate Computers!"
 
Thanks Ed,
That's more along the lines of what I need, except that I need the path, not the URL. The actual file name and location after that will be hard coded, so it's basically only the server root that's causing the problem. On my PC, it's something like C:/Websites/serverroot/ while on the Web server it's something like D:/Web Sites/ . Everything after that is the same so can be hard coded. This is for a WriteLine path to the file to which lines of HTML are being written, though I'm still not sure if the path can be done as a variable or not. Could be that I'll just have to leave it hard-coded as it is.

Don
don@ctagroup.org
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)
 
Hehe, then you misunderstood my first reply, that's what it would have given you.

If my web site on my server is physically located on my D drive underthe directory RACIING in the InetPub\ the APPL_PHYSICAL_PATH variable would result in this:

Response.Write Request.ServerVariables("APPL_PHYSICAL_PATH")

would return

C:\InetPub\So, if you're going to actually create a file using WriteLine, you would simply use APPL_PHYSICAL_PATH then tag the filename after it that you're about to create. Let's say I'm tired of talking about Daytona and wanna talk about the Poconos racetrack now LOL

Request.ServerVariables("APPL_PHYSICAL_PATH") & "poconos.htm"

That will do the trick no matter what server you move your application to. I think I just didn't explain myself enough on the first reply. =)

Let me know how it works ...
Ed (RoadRacer) Holguin

"I Hate Computers!"
 
Hi Ed,

You are absolutely right! I must have done something wrong the first time. Now, by making it into a simple variable:

[tt]path = Request.ServerVariables("APPL_PHYSICAL_PATH")[/tt]

I can concatenate "path" to the actual path string and it works perfectly! Thanks and sorry for the misunderstanding.

Don
don@ctagroup.org
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top