Re: Exceptional Error

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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" <mohitag_agrawal@xxxxxxxxxxx> wrote in message
news:1135116746.166044.74990@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>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.
>>
>> "mohit" <mohitag_agrawal@xxxxxxxxxxx> wrote in message
>> news:1135107737.374312.184290@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>> > 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.
>> >>
>> >> "mohit" <mohitag_agrawal@xxxxxxxxxxx> wrote in message
>> >> news:1135060181.222243.188940@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>> >> > 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
>> >> >
>> >
>


.



Relevant Pages

  • Re: tcl/tk on Windows: "This application has requested the Runtime to terminate it in an unusual way
    ... I assume you mean calling the 'exit' command. ... the proc 'quit' that you've written. ... Windows) as explicitly quitting Tk's even loop. ... explicitly destroy the root toplevel (a hint found via a google search, ...
    (comp.lang.tcl)
  • Re: How to set exit code of non-console app?
    ... say I have an app called "MyApp" with the following Main function: ... So it's clear from my tests that the exit code for a Windows application is ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: tcl/tk on Windows: "This application has requested the Runtime to terminate it in an unusual way
    ... the proc 'quit' that you've written. ... The more typical way to exit any Python program is to call sys.exitand indeed that works just the same (i.e. badly on Windows) as explicitly quitting Tk's even loop. ... I have found one way to get my program to exit gracefully on Windows: explicitly destroy the root toplevel before exiting. ...
    (comp.lang.tcl)
  • Re: How to set exit code of non-console app?
    ... As I understand it the result of Mainis the application's exit code. ... I don't know what you mean by "Windows applications exit immediately, ... >code and this particular application expects that the program it launches ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: window focus
    ... you CAN do it in HTML with JavaScript: ... Kevin Spencer ... > I need the current window stay on focus. ... > button to exit the window. ...
    (microsoft.public.dotnet.framework.aspnet)