Server.MapPath() localhost

W

withers

If I run Server.MapPath("/") on my operational Internet server I get,
correctly, the physical path to the directory my page is in (d:\....
\...\htdocs).

If I run Server.MapPath("/") on my intranet server, my localhost, I
get c:\inetpub\wwwroot, but my webpages are NOT in this folder, they
are in c:\webtest.

How to I establish the correct physical root on my intranet server?

Thanking you in anticipation.
 
T

TOUDIdel

Uzytkownik "withers said:
If I run Server.MapPath("/") on my operational Internet server I get,
correctly, the physical path to the directory my page is in (d:\....
\...\htdocs).

If I run Server.MapPath("/") on my intranet server, my localhost, I
get c:\inetpub\wwwroot, but my webpages are NOT in this folder, they
are in c:\webtest.

How to I establish the correct physical root on my intranet server?

c:\inetpub\wwwroot is probably correct physical path in that case. Check in
your IIS configuration console what exactly indicates wwwroot path and
change to proper if need.
 
W

withers

c:\inetpub\wwwroot is probably correct physical path in that case. Check in
your IIS configuration console what exactly indicates wwwroot path and
change to proper if need.

All my websites are in a folder c:\WebTest on my local host. For
example, the files for Web1.com are in c:\WebTest\Web1.com.

If I look at the properties of Web1.com, on the Home Directory tab the
local path is set to c:\WebTexs\Web1.com.

If I run Server.MapPath("/") from a page in Web1.com, the result is c:
\inetpub\wwwroot.

In IIS, all the virtual directories are in a folder Default Web Site.
The properties of this show a local path of c:\inetpub\wwwroot.
Server.MapPath("/") will always resolve to the local path I set in
Default Web Site properties.

I want Server.MapPath("/") to resolve to the website that runs this
command, in my example, resolve to c:\WebTest\Web1.com.

How do I set up IIS so that Server.MapPath uses the local path of the
website rather than the local path of the Default Web Site
properities?

I have noticed on my operation server in the internet, the local path
setting in Default Web Site properties is greyed out. Server.MapPath
gives the correct answer on this server.

Thanking you in anticipation.
 
A

Anthony Jones

withers said:
If I run Server.MapPath("/") on my operational Internet server I get,
correctly, the physical path to the directory my page is in (d:\....
\...\htdocs).

If I run Server.MapPath("/") on my intranet server, my localhost, I
get c:\inetpub\wwwroot, but my webpages are NOT in this folder, they
are in c:\webtest.

How to I establish the correct physical root on my intranet server?


Your local host is XP? Do really have multiple websites on the local host
or do you in fact simply have one the Default Web Site under which you've
created one or more virtual directories enabled as applications?

I think what you really need is this:-

sPath = Request.ServerVariables("APPL_PHYSICAL_PATH")
 
D

Daniel Crichton

withers wrote on Mon, 25 Feb 2008 16:17:53 -0800 (PST):
If I run Server.MapPath("/") on my operational Internet server I get,
correctly, the physical path to the directory my page is in (d:\....
\...\htdocs).
If I run Server.MapPath("/") on my intranet server, my localhost, I get
c:\inetpub\wwwroot, but my webpages are NOT in this folder, they are in
c:\webtest.
How to I establish the correct physical root on my intranet server?
Thanking you in anticipation.


Server.MapPath("/") returns the physical root for the site. If you need the
physical location for a virtual dir, try Server.MapPath("./") instead.
 
W

withers

withers wrote  on Mon, 25 Feb 2008 16:17:53 -0800 (PST):


Server.MapPath("/") returns the physical root for the site. If you need the
physical location for a virtual dir, try Server.MapPath("./") instead.

Many thanks for your help, Anthony and Dan.

Spoilt for choice! Request.ServerVariables("APPL_PHYSICAL_PATH") or
Server.MapPath("./").

Does it matter which I use?
 
A

Anthony Jones

withers wrote on Mon, 25 Feb 2008 16:17:53 -0800 (PST):

Many thanks for your help, Anthony and Dan.

Spoilt for choice! Request.ServerVariables("APPL_PHYSICAL_PATH") or
Server.MapPath("./").

Does it matter which I use?

I haven't actually tested it but it seems to me that Server.MapPath("./")
will return the physical folder that the current ASP page is found in. This
is not necesarily the same as the application physical path. If the page
executing the code is in a sub-folder with in the application folder the two
will return different results. So it depends on what you really want. The
current folder the ASP pages is running in or the root folder of the
application.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Localhost 0
Understanding VS2022 2
Server.MapPath bug? 4
Server.MapPath 2
Understanding Server.MapPath 7
Am I admin or not? 0
Server.mappath 7
Server.Mappath Help 2

Members online

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top