473,735 Members | 2,057 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Server.MapPath returning wrong path

I've got the directory f:\Company\Prod uct set as web shared so it's got a
virtual directory in the default web site on my test server's IIS. If I try
to use Server.MapPath in that site it returns a path within
c:\Inetpub\wwwr oot rather than the real path.

Can anyone please tell me why this isn't working?

Regards,
John
Jul 19 '05 #1
13 14322
Server.MapPath uses the root of the default web site as its determination of
the local folder. It doesn't actually look at individual virtual
directories, for some bizarre reason... I think it's a bug.


"John Rebbeck" <jo**@rebent.co m> wrote in message
news:On******** ******@TK2MSFTN GP11.phx.gbl...
I've got the directory f:\Company\Prod uct set as web shared so it's got a
virtual directory in the default web site on my test server's IIS. If I try to use Server.MapPath in that site it returns a path within
c:\Inetpub\wwwr oot rather than the real path.

Can anyone please tell me why this isn't working?

Regards,
John

Jul 19 '05 #2
Any way to get around it?

"Aaron Bertrand [MVP]" <aa***@TRASHasp faq.com> wrote in message
news:eW******** ******@tk2msftn gp13.phx.gbl...
Server.MapPath uses the root of the default web site as its determination of the local folder. It doesn't actually look at individual virtual
directories, for some bizarre reason... I think it's a bug.


"John Rebbeck" <jo**@rebent.co m> wrote in message
news:On******** ******@TK2MSFTN GP11.phx.gbl...
I've got the directory f:\Company\Prod uct set as web shared so it's got a virtual directory in the default web site on my test server's IIS. If I

try
to use Server.MapPath in that site it returns a path within
c:\Inetpub\wwwr oot rather than the real path.

Can anyone please tell me why this isn't working?

Regards,
John


Jul 19 '05 #3
I'm not sure but what does using the Server Variable
APPL_PHYSICAL_P ATH produce?

I think the syntax would be:
Response.Write Request.ServerV ariables("APPL_ PHYSICAL_PATH ")
Be double check that to be sure.
--

Phillip Windell [CCNA, MVP, MCP]
pw******@wandtv .com
WAND-TV (ABC Affiliate)
www.wandtv.com

"John Rebbeck" <jo**@rebent.co m> wrote in message
news:#N******** ******@TK2MSFTN GP09.phx.gbl...
Any way to get around it?

"Aaron Bertrand [MVP]" <aa***@TRASHasp faq.com> wrote in message
news:eW******** ******@tk2msftn gp13.phx.gbl...
Server.MapPath uses the root of the default web site as its determination
of
the local folder. It doesn't actually look at individual virtual
directories, for some bizarre reason... I think it's a bug.


"John Rebbeck" <jo**@rebent.co m> wrote in message
news:On******** ******@TK2MSFTN GP11.phx.gbl...
I've got the directory f:\Company\Prod uct set as web shared so
it's got
a virtual directory in the default web site on my test server's

IIS. If I try
to use Server.MapPath in that site it returns a path within
c:\Inetpub\wwwr oot rather than the real path.

Can anyone please tell me why this isn't working?

Regards,
John



Jul 19 '05 #4
> > "Aaron Bertrand [MVP]" <aa***@TRASHasp faq.com> wrote in message
news:eW******** ******@tk2msftn gp13.phx.gbl...
Server.MapPath uses the root of the default web site as its determination
of
the local folder. It doesn't actually look at individual virtual
directories, for some bizarre reason... I think it's a bug.


"John Rebbeck" <jo**@rebent.co m> wrote in message
news:On******** ******@TK2MSFTN GP11.phx.gbl...
> I've got the directory f:\Company\Prod uct set as web shared so

it's got
a
> virtual directory in the default web site on my test server's

IIS. If I try
> to use Server.MapPath in that site it returns a path within
> c:\Inetpub\wwwr oot rather than the real path.
>
> Can anyone please tell me why this isn't working?
>
> Regards,
> John
>


I can't duplicate this behavior. MapPath always returns the correct path for
me. Maybe John could post his code and physical directory structure?

--
Mark Schupp
--
Head of Development
Integrity eLearning
Online Learning Solutions Provider
ms*****@ielearn ing.com
http://www.ielearning.com
714.637.9480 x17


Jul 19 '05 #5
"Mark Schupp" <ms*****@ielear ning.com> wrote in message
news:ev******** ******@TK2MSFTN GP11.phx.gbl...
I can't duplicate this behavior. MapPath always returns the correct path for me. Maybe John could post his code and physical directory structure?


I've had it do that same to me. If you run a site from a Virtual
Folder instead of an actual Site the MapPath would use the parrent
Site as the starting point instead of the Virtual Directory root. This
is what you would run into with, say, Win2000 Pro where the IIS is
limited to one site, so each separate website runs from its own
Virtual Directory.

I got around it by just switching the Home Directory of the only Site
to what ever I needed at the moment....it is only a developement
machine so that works fine for me.

--

Phillip Windell [CCNA, MVP, MCP]
pw******@wandtv .com
WAND-TV (ABC Affiliate)
www.wandtv.com
Jul 19 '05 #6
"Phillip Windell" <pw******@wandt v.com> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
....
I've had it do that same to me. If you run a site from a Virtual
Folder instead of an actual Site the MapPath would use the parrent
Site as the starting point instead of the Virtual Directory root. This
is what you would run into with, say, Win2000 Pro where the IIS is
limited to one site, so each separate website runs from its own
Virtual Directory.


Still not clear on what you mean by each separate "website" running in its
own virtual directory when you can only have a single web site on the
system. Do you mean that there is a way to make it look like there are
multiple sites on the system? What would the URLs to 2 separate "websites"
look like?

--
Mark Schupp
--
Head of Development
Integrity eLearning
Online Learning Solutions Provider
ms*****@ielearn ing.com
http://www.ielearning.com
714.637.9480 x17
Jul 19 '05 #7
Windows 2000 server (and I assume 2003) allow more than one site on a
computer, each usually has it's own public IP

Windows 2000 and XP professional only allow a single site (Default Web Site)
"Mark Schupp" <ms*****@ielear ning.com> wrote in message
news:u$******** ******@TK2MSFTN GP09.phx.gbl...
"Phillip Windell" <pw******@wandt v.com> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
...
I've had it do that same to me. If you run a site from a Virtual
Folder instead of an actual Site the MapPath would use the parrent
Site as the starting point instead of the Virtual Directory root. This
is what you would run into with, say, Win2000 Pro where the IIS is
limited to one site, so each separate website runs from its own
Virtual Directory.


Still not clear on what you mean by each separate "website" running in its
own virtual directory when you can only have a single web site on the
system. Do you mean that there is a way to make it look like there are
multiple sites on the system? What would the URLs to 2 separate "websites"
look like?

--
Mark Schupp
--
Head of Development
Integrity eLearning
Online Learning Solutions Provider
ms*****@ielearn ing.com
http://www.ielearning.com
714.637.9480 x17

Jul 19 '05 #8
"Tom B" <sh*****@hotmai l.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Windows 2000 server (and I assume 2003) allow more than one site on a
computer, each usually has it's own public IP

Windows 2000 and XP professional only allow a single site (Default Web Site)
Yes, I know. What I am curious about is the configuration that is causing
the problem. I cannot duplicate it on my systems (2kpro or server).

I was trying to find out what the last poster meant by "If you run a site
from a Virtual Folder instead of an actual Site".

--
Mark Schupp
--
Head of Development
Integrity eLearning
Online Learning Solutions Provider
ms*****@ielearn ing.com
http://www.ielearning.com
714.637.9480 x17

"Mark Schupp" <ms*****@ielear ning.com> wrote in message
news:u$******** ******@TK2MSFTN GP09.phx.gbl...
"Phillip Windell" <pw******@wandt v.com> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
...
I've had it do that same to me. If you run a site from a Virtual
Folder instead of an actual Site the MapPath would use the parrent
Site as the starting point instead of the Virtual Directory root. This
is what you would run into with, say, Win2000 Pro where the IIS is
limited to one site, so each separate website runs from its own
Virtual Directory.


Still not clear on what you mean by each separate "website" running in its own virtual directory when you can only have a single web site on the
system. Do you mean that there is a way to make it look like there are
multiple sites on the system? What would the URLs to 2 separate "websites" look like?

--
Mark Schupp
--
Head of Development
Integrity eLearning
Online Learning Solutions Provider
ms*****@ielearn ing.com
http://www.ielearning.com
714.637.9480 x17


Jul 19 '05 #9
> Still not clear on what you mean by each separate "website" running in its
own virtual directory when you can only have a single web site on the
system. Do you mean that there is a way to make it look like there are
multiple sites on the system? What would the URLs to 2 separate "websites"
look like?


No, do this.

Under the default web site, create a virtual directory called 'foo' which
points to somewhere *other* than your normal webroot (e.g. if you use
c:\inetpub\wwwr oot\ for your webroot, create a folder called c:\whatever\
and use that folder).

Now, fuss with the permissions so you can run ASP from that folder, and
place an ASP file like this test.asp:

<%
response.write server.mappath( "/foo/test.asp")
%>

When you run it, you'll see that it returns something like:

c:\inetpub\wwwr oot\foo\test.as p

Instead of what I think it should return:

c:\whatever\tes t.asp
Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3683
by: Elie Grouchko | last post by:
Hi I am running exactly the same ASP code on IIS 5.0 and IIS 6.0 I am calling Server.MapPath(), the parameter is a virtual path that includes a reference to a parent path ("Root/Files/../Config/"). 'Config' is a virtual directory under 'Root' which is also a virtual directory. 'Files' is a normal folder. Under IIS 5.0, the path is correctly mapped to the local path of the
3
4506
by: Jon | last post by:
I'm calling Server.MapPath from global.asa through this line of code: Application("reports_dir") = Server.MapPath("Reports") The web application opens on a testing web server (not mine) at this mapped drive: M:\ And at this browser URL: http://mrs2/P2M/login.aspx I expected MapPath to map a path on the server where the application's
6
673
by: JR | last post by:
My IIS Web site has a virtual directory called content mapped to a network share. If the home directory of the Web site is c:\inetpub\wwwroot and the virtual directory maps to the network share \\myserver\content, Server.MapPath is returning c:\inetpub\wwwroot\content rather than \\myserver\content. I've tried adding <identity impersonate="true" userName="name" password="password"/> to the web.config file in order to make sure the...
6
3869
by: Nathan Sokalski | last post by:
When using the Server.MapPath() method, the results being returned are given as locations on my hard drive. I would like to be returned a result that is a URL, in my case something like the following: http://localhost/WebApplication1/WebForm1.aspx Instead, I am recieving results that are something like the following: c:/inetpub/wwwroot/WebApplication1/WebForm1.aspx
3
3989
by: Cozmo | last post by:
We have an .asp application , located in: e:\myapp In there we have directories like: e:\myapp\db e:\myapp\images e:\myapp\utils e:\myapp\working
14
12726
by: Lorenzo | last post by:
Hello, I have a web application with a virtual directory in it. With 'virtual directory' i mean a folder whose physical path is different from the physical path of the application, but in which Web Sharing is active. For example: my application is in "C:\Inetpub\wwwroot\MyApp", the Virtual folder is in "C:\VirtualFolder", and IIS sees it as if it were in "C:\Inetpub\wwwroot\MyApp\VirtualFolder".
4
7194
by: vunet.us | last post by:
How to use server.mappath() parent folder correctly: Server.MapPath("../test.asp") Thank you for the hint.
0
8786
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9463
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9200
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8202
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6747
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6049
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4562
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3274
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2740
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.