473,695 Members | 2,155 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Server.mappath

Hi,

if I write this code to retrieve a folder on the server
Server.mappath( "/DATA")

I get this error message
System.InvalidO perationExcepti on: Failed to map the path '/DATA'

the virtual folder for my webApp is not situated in Inetpub, nor is the DATA
folder that I would like to retrieve

anybody an idea

thx
Feb 23 '06 #1
7 3386
"benoit" wrote:
if I write this code to retrieve a folder on the server
Server.mappath( "/DATA")

I get this error message
System.InvalidO perationExcepti on: Failed to map the path '/DATA'

the virtual folder for my webApp is not situated in Inetpub, nor is the
DATA
folder that I would like to retrieve


I doesn't need to be in Inetpub.

Is "data" the name of a folder inside your webapp? If so, shouldn't your
line read Server.mappath( "/WebApp/Data") ?

Steven

- - -
Feb 23 '06 #2
Benoit,
Server.MapPath( ...) works starting at the IIS Virtual directory root of the
currently running application page.
It does not work for folders anywhere outside the IIS Vroot of the current
application.

What is it that you are trying to accomplish?
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"benoit" wrote:
Hi,

if I write this code to retrieve a folder on the server
Server.mappath( "/DATA")

I get this error message
System.InvalidO perationExcepti on: Failed to map the path '/DATA'

the virtual folder for my webApp is not situated in Inetpub, nor is the DATA
folder that I would like to retrieve

anybody an idea

thx

Feb 23 '06 #3
Well

On ASP.NET 1.1 I had two webapps on the same server
/WNW
and
/Data

/Data was a virtual folder in which images and Xml are stored.
With Server.MapPath( "/Data") i could without any problem read my Xml and
images.
Since I made the move to ASP.Net 2.0, I am no longer able to retrieve my
data the way I used to


"Peter Bromberg [C# MVP]" wrote:
Benoit,
Server.MapPath( ...) works starting at the IIS Virtual directory root of the
currently running application page.
It does not work for folders anywhere outside the IIS Vroot of the current
application.

What is it that you are trying to accomplish?
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"benoit" wrote:
Hi,

if I write this code to retrieve a folder on the server
Server.mappath( "/DATA")

I get this error message
System.InvalidO perationExcepti on: Failed to map the path '/DATA'

the virtual folder for my webApp is not situated in Inetpub, nor is the DATA
folder that I would like to retrieve

anybody an idea

thx

Feb 23 '06 #4
"benoit" wrote:
On ASP.NET 1.1 I had two webapps on the same server
/WNW
and
/Data

/Data was a virtual folder in which images and Xml are stored.
With Server.MapPath( "/Data") i could without any problem read my Xml and
images.
Since I made the move to ASP.Net 2.0, I am no longer able to retrieve my
data the way I used to


IIRC, this is a security issue. What about putting a virtual dir in /WNW
called "Data" that points to the same location as /Data? That way you can
use Server.MapPath( "/WNW/Data");

Steven

- - -


Feb 23 '06 #5
That's strange.

I can retrieve physical paths by using Server.MapPath( "/virtualDir")
without any problem.

mappath.aspx:
----------------
<%@ Page Language="VB" %>
<script language = "VB" runat = "server">
Sub Page_Load(ByVal obj As Object, ByVal e As EventArgs)
Dim x As String = Server.MapPath( "/SomeApp")
Label1.Text = "The physical directory for /SomeApp is : " & x
End Sub
</script>
<html>
<head runat="server">
<title>Server.M apPath</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server"> </asp:Label><br/>
</div>
</form>
</body>
</html>
----------------

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
"benoit" <be****@discuss ions.microsoft. com> wrote in message
news:DF******** *************** ***********@mic rosoft.com...
Well

On ASP.NET 1.1 I had two webapps on the same server
/WNW
and
/Data

/Data was a virtual folder in which images and Xml are stored.
With Server.MapPath( "/Data") i could without any problem read my Xml and
images.
Since I made the move to ASP.Net 2.0, I am no longer able to retrieve my
data the way I used to


"Peter Bromberg [C# MVP]" wrote:
Benoit,
Server.MapPath( ...) works starting at the IIS Virtual directory root of the
currently running application page.
It does not work for folders anywhere outside the IIS Vroot of the current
application.

What is it that you are trying to accomplish?
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"benoit" wrote:
> Hi,
>
> if I write this code to retrieve a folder on the server
> Server.mappath( "/DATA")
>
> I get this error message
> System.InvalidO perationExcepti on: Failed to map the path '/DATA'
>
> the virtual folder for my webApp is not situated in Inetpub, nor is the DATA
> folder that I would like to retrieve
>
> anybody an idea
>
> thx

Feb 23 '06 #6
I noticed that when i teste the app in the past the address
was http://localhost/MyApp/...
and now http://localhost:someport/MyApp

Does it have something to do with that?

"Juan T. Llibre" wrote:
That's strange.

I can retrieve physical paths by using Server.MapPath( "/virtualDir")
without any problem.

mappath.aspx:
----------------
<%@ Page Language="VB" %>
<script language = "VB" runat = "server">
Sub Page_Load(ByVal obj As Object, ByVal e As EventArgs)
Dim x As String = Server.MapPath( "/SomeApp")
Label1.Text = "The physical directory for /SomeApp is : " & x
End Sub
</script>
<html>
<head runat="server">
<title>Server.M apPath</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server"> </asp:Label><br/>
</div>
</form>
</body>
</html>
----------------

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
"benoit" <be****@discuss ions.microsoft. com> wrote in message
news:DF******** *************** ***********@mic rosoft.com...
Well

On ASP.NET 1.1 I had two webapps on the same server
/WNW
and
/Data

/Data was a virtual folder in which images and Xml are stored.
With Server.MapPath( "/Data") i could without any problem read my Xml and
images.
Since I made the move to ASP.Net 2.0, I am no longer able to retrieve my
data the way I used to


"Peter Bromberg [C# MVP]" wrote:
Benoit,
Server.MapPath( ...) works starting at the IIS Virtual directory root of the
currently running application page.
It does not work for folders anywhere outside the IIS Vroot of the current
application.

What is it that you are trying to accomplish?
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"benoit" wrote:

> Hi,
>
> if I write this code to retrieve a folder on the server
> Server.mappath( "/DATA")
>
> I get this error message
> System.InvalidO perationExcepti on: Failed to map the path '/DATA'
>
> the virtual folder for my webApp is not situated in Inetpub, nor is the DATA
> folder that I would like to retrieve
>
> anybody an idea
>
> thx


Feb 23 '06 #7
re:
Does it have something to do with that?
Server.MapPath returns the correct physical directory regardless of whether
you use the built-in server in the VS IDE, or whether you use IIS to view the page.

All it needs is a valid relative URL ( a virtual path ).

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
"benoit" <be****@discuss ions.microsoft. com> wrote in message
news:93******** *************** ***********@mic rosoft.com...I noticed that when i teste the app in the past the address
was http://localhost/MyApp/...
and now http://localhost:someport/MyApp

Does it have something to do with that? "Juan T. Llibre" wrote:
That's strange.

I can retrieve physical paths by using Server.MapPath( "/virtualDir")
without any problem.

mappath.aspx:
----------------
<%@ Page Language="VB" %>
<script language = "VB" runat = "server">
Sub Page_Load(ByVal obj As Object, ByVal e As EventArgs)
Dim x As String = Server.MapPath( "/SomeApp")
Label1.Text = "The physical directory for /SomeApp is : " & x
End Sub
</script>
<html>
<head runat="server">
<title>Server.M apPath</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server"> </asp:Label><br/>
</div>
</form>
</body>
</html>
----------------

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
"benoit" <be****@discuss ions.microsoft. com> wrote in message
news:DF******** *************** ***********@mic rosoft.com...
> Well
>
> On ASP.NET 1.1 I had two webapps on the same server
> /WNW
> and
> /Data
>
> /Data was a virtual folder in which images and Xml are stored.
> With Server.MapPath( "/Data") i could without any problem read my Xml and
> images.
> Since I made the move to ASP.Net 2.0, I am no longer able to retrieve my
> data the way I used to
>
>
>
>
> "Peter Bromberg [C# MVP]" wrote:
>
>> Benoit,
>> Server.MapPath( ...) works starting at the IIS Virtual directory root of the
>> currently running application page.
>> It does not work for folders anywhere outside the IIS Vroot of the current
>> application.
>>
>> What is it that you are trying to accomplish?
>> Peter
>>
>> --
>> Co-founder, Eggheadcafe.com developer portal:
>> http://www.eggheadcafe.com
>> UnBlog:
>> http://petesbloggerama.blogspot.com
>>
>>
>>
>>
>> "benoit" wrote:
>>
>> > Hi,
>> >
>> > if I write this code to retrieve a folder on the server
>> > Server.mappath( "/DATA")
>> >
>> > I get this error message
>> > System.InvalidO perationExcepti on: Failed to map the path '/DATA'
>> >
>> > the virtual folder for my webApp is not situated in Inetpub, nor is the DATA
>> > folder that I would like to retrieve
>> >
>> > anybody an idea
>> >
>> > thx


Feb 23 '06 #8

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

Similar topics

13
14317
by: John Rebbeck | last post by:
I've got the directory f:\Company\Product 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\wwwroot rather than the real path. Can anyone please tell me why this isn't working? Regards, John
4
1928
by: Laphan | last post by:
Hi All Sorry to be irate, but the whole concept of Server.MapPaths really has me in a tiswas!! In order to confirm once and for all, could you please advise me on the following: 1) There is no difference in putting '/' or '\' in the Server.MapPath param, eg Server.MapPath("/fred/test.asp") or Server.MapPath("\fred\test.asp") -
6
1602
by: darrel | last post by:
I have some functions that are reading/writing to the file system. As such, they use server.mapPath a lot to navigate it all. Since I'm using these functions numerous times throughout my application, I thought I'd move these into their own .vb class file and reference them that way. The catch is when moving these scripts over, 'Server.MapPath' turns into an error "Name 'server' is not declared"
14
12715
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".
5
9619
by: MichiMichi | last post by:
When using Server.MapPath on IIS 5 on my localhost everything works well. All of the following commands are executed without any error Response.Write(Server.MapPath("/app_test") & "<br>") Response.Write(Server.MapPath("app_test") & "<br>") Response.Write(Server.MapPath("~") & "<br>") However, running the first statement on via the internal Visual Studio 2005 Server I receive an error for
4
7186
by: vunet.us | last post by:
How to use server.mappath() parent folder correctly: Server.MapPath("../test.asp") Thank you for the hint.
3
15062
by: rn5a | last post by:
Server.MapPath returns the physical file path that corresponds to the specified virtual path whereas Request.MapPath maps the specified virtual path to a physical path. Assuming that a file named Hello.aspx resides in C:\Inetpub\wwwroot\MyFolder, the output of both Response.Write(Server.MapPath("Hello.aspx")) & Response.Write(Request.MapPath("Hello.aspx"))
6
7939
by: withers | last post by:
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?
3
4123
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have one line code in my program, occasionaly I will receive the following error: "The Path parameter for the MapPath method did not correspond to a known path" Path=Server.MapPath(sCertPath & "\" & order_id & ".pdf") I am wondering what is happening since every time I check my error log, the
0
8553
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
9112
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
8971
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8822
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7650
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
6483
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
5827
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
4332
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...
2
2251
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.