473,387 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Server.mappath

Hi,

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

I get this error message
System.InvalidOperationException: 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 3358
"benoit" wrote:
if I write this code to retrieve a folder on the server
Server.mappath("/DATA")

I get this error message
System.InvalidOperationException: 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.InvalidOperationException: 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.InvalidOperationException: 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.MapPath</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****@discussions.microsoft.com> wrote in message
news:DF**********************************@microsof t.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.InvalidOperationException: 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.MapPath</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****@discussions.microsoft.com> wrote in message
news:DF**********************************@microsof t.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.InvalidOperationException: 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****@discussions.microsoft.com> wrote in message
news:93**********************************@microsof t.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.MapPath</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****@discussions.microsoft.com> wrote in message
news:DF**********************************@microsof t.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.InvalidOperationException: 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
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...
4
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...
6
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...
14
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...
5
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>")...
4
by: vunet.us | last post by:
How to use server.mappath() parent folder correctly: Server.MapPath("../test.asp") Thank you for the hint.
3
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...
6
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...
3
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" ...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...

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.