Exceptional Error

M

mohit

Hi,
I am creating a web application in Web Matrix on the .NET
framework.
I have two directories :AddUser and FormAuth in a Directory P.

AddUser contains a file AddUser.aspx
FormAuth contains : Default.aspx , Users.xml , Login.aspx

I have the following code :

DataSet ds = new DataSet();

String userFile = "../Users.xml";

FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);
StreamReader reader = new StreamReader(fs);
ds.ReadXml(reader);
fs.Close();


When I run it it gives the following exception :

[HttpException (0x80004005): Cannot use a leading .. to exit above the
top directory.]
System.Web.Util.UrlPath.Reduce(String path) +581
System.Web.Util.UrlPath.Combine(String basepath, String relative)
+251
System.Web.HttpRequest.MapPath(String virtualPath, String
baseVirtualDir, Boolean allowCrossAppMapping) +192
System.Web.HttpServerUtility.MapPath(String path) +61
ASP.AddUser_aspx.Button1_Click(Object sender, EventArgs e) in F:\DC
Downlaods(complete)\mohitag\MyProject\AddUser\AddUser.aspx:28
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +83

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1263

IF YOU HAVE SOME IDEA PLEASE TELL ME AS SOON AS POSSIBLE.

Thank you very much
 
K

Kevin Spencer

Your web server doesn't allow parent paths. You either have to use a
root-relative path, and absolute path, or configure your web server to allow
parent paths.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
 
M

mohit

Neither the root relative path nor the absolute path are working.
could you please tell me how to configure windows to allow parent
paths.
Thanks

Kevin said:
Your web server doesn't allow parent paths. You either have to use a
root-relative path, and absolute path, or configure your web server to allow
parent paths.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

mohit said:
Hi,
I am creating a web application in Web Matrix on the .NET
framework.
I have two directories :AddUser and FormAuth in a Directory P.

AddUser contains a file AddUser.aspx
FormAuth contains : Default.aspx , Users.xml , Login.aspx

I have the following code :

DataSet ds = new DataSet();

String userFile = "../Users.xml";

FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);
StreamReader reader = new StreamReader(fs);
ds.ReadXml(reader);
fs.Close();


When I run it it gives the following exception :

[HttpException (0x80004005): Cannot use a leading .. to exit above the
top directory.]
System.Web.Util.UrlPath.Reduce(String path) +581
System.Web.Util.UrlPath.Combine(String basepath, String relative)
+251
System.Web.HttpRequest.MapPath(String virtualPath, String
baseVirtualDir, Boolean allowCrossAppMapping) +192
System.Web.HttpServerUtility.MapPath(String path) +61
ASP.AddUser_aspx.Button1_Click(Object sender, EventArgs e) in F:\DC
Downlaods(complete)\mohitag\MyProject\AddUser\AddUser.aspx:28
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +83

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1263

IF YOU HAVE SOME IDEA PLEASE TELL ME AS SOON AS POSSIBLE.

Thank you very much
 
K

Kevin Spencer

This is done through the IIS Admin tool, not Windows. Web Site Properties -
Home Directory Tab - Configure Button - Options Tab.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

mohit said:
Neither the root relative path nor the absolute path are working.
could you please tell me how to configure windows to allow parent
paths.
Thanks

Kevin said:
Your web server doesn't allow parent paths. You either have to use a
root-relative path, and absolute path, or configure your web server to
allow
parent paths.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

mohit said:
Hi,
I am creating a web application in Web Matrix on the .NET
framework.
I have two directories :AddUser and FormAuth in a Directory P.

AddUser contains a file AddUser.aspx
FormAuth contains : Default.aspx , Users.xml , Login.aspx

I have the following code :

DataSet ds = new DataSet();

String userFile = "../Users.xml";

FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);
StreamReader reader = new StreamReader(fs);
ds.ReadXml(reader);
fs.Close();


When I run it it gives the following exception :

[HttpException (0x80004005): Cannot use a leading .. to exit above the
top directory.]
System.Web.Util.UrlPath.Reduce(String path) +581
System.Web.Util.UrlPath.Combine(String basepath, String relative)
+251
System.Web.HttpRequest.MapPath(String virtualPath, String
baseVirtualDir, Boolean allowCrossAppMapping) +192
System.Web.HttpServerUtility.MapPath(String path) +61
ASP.AddUser_aspx.Button1_Click(Object sender, EventArgs e) in F:\DC
Downlaods(complete)\mohitag\MyProject\AddUser\AddUser.aspx:28
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +83

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1263

IF YOU HAVE SOME IDEA PLEASE TELL ME AS SOON AS POSSIBLE.

Thank you very much
 
M

mohit

I have tried it. I am using IIS in Windows XP.
The errors are as following :

if the code is : String userFile = "../Users.xml";

FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);


Error is :Exception Details: System.Web.HttpException: Cannot use a
leading .. to exit above the top directory.

If the code is : String userFile = "FormsAuth/Users.xml"; or
"/FormsAuth/Users.xml"

FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);


Error :Exception Details: System.IO.DirectoryNotFoundException: Could
not find a part of the path "F:\DC
Downlaods(complete)\mohitag\MyProject\AddUser\FormsAuth\Users.xml".

If the code is: String userFile = "F:\DC
Downlaods(complete)\mohitag\MyProject\FormsAuth\Users.xml";

FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);


Error : Compiler Error Message: CS1009: Unrecognized escape sequence

Thank you very much.

Kevin said:
This is done through the IIS Admin tool, not Windows. Web Site Properties -
Home Directory Tab - Configure Button - Options Tab.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

mohit said:
Neither the root relative path nor the absolute path are working.
could you please tell me how to configure windows to allow parent
paths.
Thanks

Kevin said:
Your web server doesn't allow parent paths. You either have to use a
root-relative path, and absolute path, or configure your web server to
allow
parent paths.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

Hi,
I am creating a web application in Web Matrix on the .NET
framework.
I have two directories :AddUser and FormAuth in a Directory P.

AddUser contains a file AddUser.aspx
FormAuth contains : Default.aspx , Users.xml , Login.aspx

I have the following code :

DataSet ds = new DataSet();

String userFile = "../Users.xml";

FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);
StreamReader reader = new StreamReader(fs);
ds.ReadXml(reader);
fs.Close();


When I run it it gives the following exception :

[HttpException (0x80004005): Cannot use a leading .. to exit above the
top directory.]
System.Web.Util.UrlPath.Reduce(String path) +581
System.Web.Util.UrlPath.Combine(String basepath, String relative)
+251
System.Web.HttpRequest.MapPath(String virtualPath, String
baseVirtualDir, Boolean allowCrossAppMapping) +192
System.Web.HttpServerUtility.MapPath(String path) +61
ASP.AddUser_aspx.Button1_Click(Object sender, EventArgs e) in F:\DC
Downlaods(complete)\mohitag\MyProject\AddUser\AddUser.aspx:28
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +83

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1263

IF YOU HAVE SOME IDEA PLEASE TELL ME AS SOON AS POSSIBLE.

Thank you very much
 
K

Kevin Spencer

You have 4 distinctly different problems here:

(1)
String userFile = "../Users.xml";

FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);
Error is :Exception Details: System.Web.HttpException: Cannot use a
leading .. to exit above the top directory.

This would indicate that the current HttpContext of the Page is in the root
(top) directory of the app. The ".." indicates a directory above that one,
which is below the top directory, and therefore outside the ASP.Net app.
This is a security feature of ASP.Net. You can use a root-relative path
instead, such as: "/Users.xml"

(2)
String userFile = "FormsAuth/Users.xml"; or
"/FormsAuth/Users.xml"

FileStream fs = new FileStream(Server.MapPath(userFile),
Error :Exception Details: System.IO.DirectoryNotFoundException: Could
not find a part of the path "F:\DC
Downlaods(complete)\mohitag\MyProject\AddUser\FormsAuth\Users.xml".

The path that is indicated in the error message doesn't exist.

(3)
String userFile = "F:\DC
Downlaods(complete)\mohitag\MyProject\FormsAuth\Users.xml";

FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);
Error : Compiler Error Message: CS1009: Unrecognized escape sequence

The "\" character in C# is an escape sequence. You have to escape it with
another "\" character (as in "\\" to represent a "\" character in a string.

(4)
You're programming by guesswork. This is the biggest problem of all. It will
cost you beaucoups time. Do you have the Microsoft .Net SDK? You can
download it for free from:

http://msdn.microsoft.com/netframework/downloads/updates/default.aspx

This page has links to the Framework SDK for both 1.1 and 2.0 framework
versions.

You'll save yourself a lot of time by using it. Ever since the first version
of the Framework was released, I've spent about an hour a day on average
reading in it.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.


mohit said:
I have tried it. I am using IIS in Windows XP.
The errors are as following :

if the code is : String userFile = "../Users.xml";

FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);


Error is :Exception Details: System.Web.HttpException: Cannot use a
leading .. to exit above the top directory.

If the code is : String userFile = "FormsAuth/Users.xml"; or
"/FormsAuth/Users.xml"

FileStream fs = new FileStream(Server.MapPath(userFile),


Error :Exception Details: System.IO.DirectoryNotFoundException: Could
not find a part of the path "F:\DC
Downlaods(complete)\mohitag\MyProject\AddUser\FormsAuth\Users.xml".

If the code is: String userFile = "F:\DC
Downlaods(complete)\mohitag\MyProject\FormsAuth\Users.xml";

FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);


Error : Compiler Error Message: CS1009: Unrecognized escape sequence

Thank you very much.

Kevin said:
This is done through the IIS Admin tool, not Windows. Web Site
Properties -
Home Directory Tab - Configure Button - Options Tab.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

mohit said:
Neither the root relative path nor the absolute path are working.
could you please tell me how to configure windows to allow parent
paths.
Thanks

Kevin Spencer wrote:
Your web server doesn't allow parent paths. You either have to use a
root-relative path, and absolute path, or configure your web server to
allow
parent paths.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

Hi,
I am creating a web application in Web Matrix on the .NET
framework.
I have two directories :AddUser and FormAuth in a Directory P.

AddUser contains a file AddUser.aspx
FormAuth contains : Default.aspx , Users.xml , Login.aspx

I have the following code :

DataSet ds = new DataSet();

String userFile = "../Users.xml";

FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);
StreamReader reader = new StreamReader(fs);
ds.ReadXml(reader);
fs.Close();


When I run it it gives the following exception :

[HttpException (0x80004005): Cannot use a leading .. to exit above
the
top directory.]
System.Web.Util.UrlPath.Reduce(String path) +581
System.Web.Util.UrlPath.Combine(String basepath, String relative)
+251
System.Web.HttpRequest.MapPath(String virtualPath, String
baseVirtualDir, Boolean allowCrossAppMapping) +192
System.Web.HttpServerUtility.MapPath(String path) +61
ASP.AddUser_aspx.Button1_Click(Object sender, EventArgs e) in
F:\DC
Downlaods(complete)\mohitag\MyProject\AddUser\AddUser.aspx:28
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +83

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1263

IF YOU HAVE SOME IDEA PLEASE TELL ME AS SOON AS POSSIBLE.

Thank you very much
 
M

mohit

Following your instructions when I give the absolute path it says that
the path is invalid and asks for virtual path.
When I give the virtual path it says that the path does not exist.I
have even configured my web server for the parent path.
This all is becoming very messy to me.I am unable to understand where
the major mistake is.

Please guide me.

Thank you.

Kevin said:
You have 4 distinctly different problems here:

(1)
String userFile = "../Users.xml";

FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);
Error is :Exception Details: System.Web.HttpException: Cannot use a
leading .. to exit above the top directory.

This would indicate that the current HttpContext of the Page is in the root
(top) directory of the app. The ".." indicates a directory above that one,
which is below the top directory, and therefore outside the ASP.Net app.
This is a security feature of ASP.Net. You can use a root-relative path
instead, such as: "/Users.xml"

(2)
String userFile = "FormsAuth/Users.xml"; or
"/FormsAuth/Users.xml"

FileStream fs = new FileStream(Server.MapPath(userFile),
Error :Exception Details: System.IO.DirectoryNotFoundException: Could
not find a part of the path "F:\DC
Downlaods(complete)\mohitag\MyProject\AddUser\FormsAuth\Users.xml".

The path that is indicated in the error message doesn't exist.

(3)
String userFile = "F:\DC
Downlaods(complete)\mohitag\MyProject\FormsAuth\Users.xml";

FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);
Error : Compiler Error Message: CS1009: Unrecognized escape sequence

The "\" character in C# is an escape sequence. You have to escape it with
another "\" character (as in "\\" to represent a "\" character in a string.

(4)
You're programming by guesswork. This is the biggest problem of all. It will
cost you beaucoups time. Do you have the Microsoft .Net SDK? You can
download it for free from:

http://msdn.microsoft.com/netframework/downloads/updates/default.aspx

This page has links to the Framework SDK for both 1.1 and 2.0 framework
versions.

You'll save yourself a lot of time by using it. Ever since the first version
of the Framework was released, I've spent about an hour a day on average
reading in it.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.


mohit said:
I have tried it. I am using IIS in Windows XP.
The errors are as following :

if the code is : String userFile = "../Users.xml";

FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);


Error is :Exception Details: System.Web.HttpException: Cannot use a
leading .. to exit above the top directory.

If the code is : String userFile = "FormsAuth/Users.xml"; or
"/FormsAuth/Users.xml"

FileStream fs = new FileStream(Server.MapPath(userFile),


Error :Exception Details: System.IO.DirectoryNotFoundException: Could
not find a part of the path "F:\DC
Downlaods(complete)\mohitag\MyProject\AddUser\FormsAuth\Users.xml".

If the code is: String userFile = "F:\DC
Downlaods(complete)\mohitag\MyProject\FormsAuth\Users.xml";

FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);


Error : Compiler Error Message: CS1009: Unrecognized escape sequence

Thank you very much.

Kevin said:
This is done through the IIS Admin tool, not Windows. Web Site
Properties -
Home Directory Tab - Configure Button - Options Tab.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

Neither the root relative path nor the absolute path are working.
could you please tell me how to configure windows to allow parent
paths.
Thanks

Kevin Spencer wrote:
Your web server doesn't allow parent paths. You either have to use a
root-relative path, and absolute path, or configure your web server to
allow
parent paths.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

Hi,
I am creating a web application in Web Matrix on the .NET
framework.
I have two directories :AddUser and FormAuth in a Directory P.

AddUser contains a file AddUser.aspx
FormAuth contains : Default.aspx , Users.xml , Login.aspx

I have the following code :

DataSet ds = new DataSet();

String userFile = "../Users.xml";

FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);
StreamReader reader = new StreamReader(fs);
ds.ReadXml(reader);
fs.Close();


When I run it it gives the following exception :

[HttpException (0x80004005): Cannot use a leading .. to exit above
the
top directory.]
System.Web.Util.UrlPath.Reduce(String path) +581
System.Web.Util.UrlPath.Combine(String basepath, String relative)
+251
System.Web.HttpRequest.MapPath(String virtualPath, String
baseVirtualDir, Boolean allowCrossAppMapping) +192
System.Web.HttpServerUtility.MapPath(String path) +61
ASP.AddUser_aspx.Button1_Click(Object sender, EventArgs e) in
F:\DC
Downlaods(complete)\mohitag\MyProject\AddUser\AddUser.aspx:28
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +83

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1263

IF YOU HAVE SOME IDEA PLEASE TELL ME AS SOON AS POSSIBLE.

Thank you very much
 
K

Kevin Spencer

It's pretty simple really. The constructior for FileStream requires a file
path to a file. This is not the same as a URL or virtual path. Now, you're
running an ASP.Net application, which works in the context of a web server,
and virtual directories. So, how you get the full file path to the file can
be any number of ways. You can type it into your code as a literal string:

string filePath = @"C:\inetpub\wwwroot\yourAppRoot\somefolder\somefile.xml";

- or -

string filePath =
"C:\\inetpub\\wwwroot\\yourAppRoot\\somefolder\\somefile.xml";

You can derive the file path from a web server virtual directory path, as
long as the file is under the root folder of your ASP.Net application:

string filePath = Server.MapPath("/somefolder/somefile.xml"); //
root-relative

string filePath = Server.MapPath("../somefolder/somefile.xml"); // relative
to current Page

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.



mohit said:
Following your instructions when I give the absolute path it says that
the path is invalid and asks for virtual path.
When I give the virtual path it says that the path does not exist.I
have even configured my web server for the parent path.
This all is becoming very messy to me.I am unable to understand where
the major mistake is.

Please guide me.

Thank you.

Kevin said:
You have 4 distinctly different problems here:

(1)
String userFile = "../Users.xml";

FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);
Error is :Exception Details: System.Web.HttpException: Cannot use a
leading .. to exit above the top directory.

This would indicate that the current HttpContext of the Page is in the
root
(top) directory of the app. The ".." indicates a directory above that
one,
which is below the top directory, and therefore outside the ASP.Net app.
This is a security feature of ASP.Net. You can use a root-relative path
instead, such as: "/Users.xml"

(2)
String userFile = "FormsAuth/Users.xml"; or
"/FormsAuth/Users.xml"

FileStream fs = new FileStream(Server.MapPath(userFile),
Error :Exception Details: System.IO.DirectoryNotFoundException: Could
not find a part of the path "F:\DC
Downlaods(complete)\mohitag\MyProject\AddUser\FormsAuth\Users.xml".

The path that is indicated in the error message doesn't exist.

(3)
String userFile = "F:\DC
Downlaods(complete)\mohitag\MyProject\FormsAuth\Users.xml";

FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);
Error : Compiler Error Message: CS1009: Unrecognized escape sequence

The "\" character in C# is an escape sequence. You have to escape it with
another "\" character (as in "\\" to represent a "\" character in a
string.

(4)
You're programming by guesswork. This is the biggest problem of all. It
will
cost you beaucoups time. Do you have the Microsoft .Net SDK? You can
download it for free from:

http://msdn.microsoft.com/netframework/downloads/updates/default.aspx

This page has links to the Framework SDK for both 1.1 and 2.0 framework
versions.

You'll save yourself a lot of time by using it. Ever since the first
version
of the Framework was released, I've spent about an hour a day on average
reading in it.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.


mohit said:
I have tried it. I am using IIS in Windows XP.
The errors are as following :

if the code is : String userFile = "../Users.xml";

FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);


Error is :Exception Details: System.Web.HttpException: Cannot use a
leading .. to exit above the top directory.

If the code is : String userFile = "FormsAuth/Users.xml"; or
"/FormsAuth/Users.xml"

FileStream fs = new FileStream(Server.MapPath(userFile),


Error :Exception Details: System.IO.DirectoryNotFoundException: Could
not find a part of the path "F:\DC
Downlaods(complete)\mohitag\MyProject\AddUser\FormsAuth\Users.xml".

If the code is: String userFile = "F:\DC
Downlaods(complete)\mohitag\MyProject\FormsAuth\Users.xml";

FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);


Error : Compiler Error Message: CS1009: Unrecognized escape sequence

Thank you very much.

Kevin Spencer wrote:
This is done through the IIS Admin tool, not Windows. Web Site
Properties -
Home Directory Tab - Configure Button - Options Tab.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

Neither the root relative path nor the absolute path are working.
could you please tell me how to configure windows to allow parent
paths.
Thanks

Kevin Spencer wrote:
Your web server doesn't allow parent paths. You either have to use
a
root-relative path, and absolute path, or configure your web server
to
allow
parent paths.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

Hi,
I am creating a web application in Web Matrix on the .NET
framework.
I have two directories :AddUser and FormAuth in a Directory P.

AddUser contains a file AddUser.aspx
FormAuth contains : Default.aspx , Users.xml , Login.aspx

I have the following code :

DataSet ds = new DataSet();

String userFile = "../Users.xml";

FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);
StreamReader reader = new StreamReader(fs);
ds.ReadXml(reader);
fs.Close();


When I run it it gives the following exception :

[HttpException (0x80004005): Cannot use a leading .. to exit
above
the
top directory.]
System.Web.Util.UrlPath.Reduce(String path) +581
System.Web.Util.UrlPath.Combine(String basepath, String
relative)
+251
System.Web.HttpRequest.MapPath(String virtualPath, String
baseVirtualDir, Boolean allowCrossAppMapping) +192
System.Web.HttpServerUtility.MapPath(String path) +61
ASP.AddUser_aspx.Button1_Click(Object sender, EventArgs e) in
F:\DC
Downlaods(complete)\mohitag\MyProject\AddUser\AddUser.aspx:28
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +83

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1263

IF YOU HAVE SOME IDEA PLEASE TELL ME AS SOON AS POSSIBLE.

Thank you very much
 
M

mohit

I understood it.But I don't understand one thing that why my program is
giving error.
Actually with the constructor FileStream we should give virtual
path.But when I provide
it virtual path it gives the error that the path does not exist.That is
what the major problem is.
I have configured my web server too.

Ideas ??

Thank you.
 

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

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top