469,950 Members | 1,476 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

Server.MapPath() localhost

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.

Feb 26 '08 #1
6 7668

Uzytkownik "withers" <ro***@upperbridge.co.uknapisal w wiadomosci
news:e0**********************************@34g2000h sz.googlegroups.com...
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.
--
td
Feb 26 '08 #2
On Feb 26, 8:13*am, "TOUDIdel" <toudi...@oDWA.plwrote:
Uzytkownik "withers" <ro...@upperbridge.co.uknapisal w wiadomoscinews:e0********************************* *@34g2000hsz.googlegroups.com...
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.
--
td
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.
Feb 26 '08 #3
"withers" <ro***@upperbridge.co.ukwrote in message
news:e0**********************************@34g2000h sz.googlegroups.com...
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")
--
Anthony Jones - MVP ASP/ASP.NET
Feb 26 '08 #4
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.

--
Dan
Feb 26 '08 #5
On Feb 26, 12:55*pm, "Daniel Crichton" <msn...@worldofspack.com>
wrote:
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.

--
Dan
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?
Feb 26 '08 #6
"withers" <ro***@upperbridge.co.ukwrote in message
news:eb**********************************@e23g2000 prf.googlegroups.com...
On Feb 26, 12:55 pm, "Daniel Crichton" <msn...@worldofspack.com>
wrote:
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.

--
Anthony Jones - MVP ASP/ASP.NET
Feb 26 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Steve | last post: by
2 posts views Thread by Jim Heavey | last post: by
10 posts views Thread by Kenneth P | last post: by
6 posts views Thread by Nathan Sokalski | last post: by
7 posts views Thread by benoit | last post: by
14 posts views Thread by Lorenzo | last post: by
5 posts views Thread by MichiMichi | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.