ASP.Net app cannot read XML with Anonymous Authentication disabled

From: Daniel Dinucci (djd@dolby.com)
Date: 10/31/02


From: "Daniel Dinucci" <djd@dolby.com>
Date: Thu, 31 Oct 2002 10:36:05 -0800


I've been working on a simple ASP.Net application. The app reads a couple of
real simple XML files from it's local directory. The problem I'm having is
that the application will not read these files when I disable Allow
Anonymous Access to the site. It throws an unauthorized error (below). I've
tried applying the local ASPNET user to the folder permissions list with no
luck.

Since disabling Allow Anonymous Access is a requirement and so is reading
these xml files, would you know of a solution to this problem or somewhere I
can go look.

Thanks in advance for your expertise.

~Dan

More details:

Here is the code excerpt

Dim reader As XmlReader = Nothing

Dim ProjReader As XmlReader = Nothing

Dim RoomURL As String = Session("RoomListURL")

Dim ProjURL As String = Session("ProjectorListURL")

Dim RedirectURL As String

Try

'Get XML Data for Rooms and load in Room dropdown

reader = New XmlTextReader(RoomURL)

Location.Items.Add("Select Location")

While (reader.Read())

If reader.NodeType = XmlNodeType.Element And reader.Name = "room" Then
Location.Items.Add(reader.ReadString.ToString)

End While

'Get XML Data for Projector and load in Projector Dropdown

ProjReader = New XmlTextReader(ProjURL)

LCDProjector.Items.Add("Select Projector")

While (ProjReader.Read())

If ProjReader.NodeType = XmlNodeType.Element And ProjReader.Name =
"projector" Then LCDProjector.Items.Add(ProjReader.ReadString.ToString)

End While

Catch ex As Exception

RedirectURL = "Fail.aspx?msg=Problem Loading Drop Downs."

Response.Redirect(RedirectURL)

Finally

If Not reader Is Nothing Then

reader.Close()

End If

If Not ProjReader Is Nothing Then

ProjReader.Close()

End If

End Try

Here is the error it throws:

Server Error in '/EventPlanning' Application.

The remote server returned an error: (401) Unauthorized.

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Net.WebException: The remote server returned an
error: (401) Unauthorized.

Source Error:

      Line 291: reader = New XmlTextReader(RoomURL)

      Line 292: Location.Items.Add("Select Location")

      Line 293: While (reader.Read())

      Line 294: If reader.NodeType = XmlNodeType.Element And reader.Name =
"room" Then Location.Items.Add(reader.ReadString.ToString)

      Line 295: End While

Source File: c:\inetpub\wwwroot\EventPlanning\AddEvent.aspx.vb Line: 293

Stack Trace:

      [WebException: The remote server returned an error: (401)
Unauthorized.]

      System.Net.HttpWebRequest.CheckFinalStatus()

      System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)

      System.Net.HttpWebRequest.GetResponse()

      System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials
credentials)

      System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials
credentials) +94

      System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type
ofObjectToReturn) +55

      System.Xml.XmlTextReader.CreateScanner() +170

      System.Xml.XmlTextReader.Init() +23

      System.Xml.XmlTextReader.Read() +530

      EventPlanning.WebForm2.LoadDropdowns() in
c:\inetpub\wwwroot\EventPlanning\AddEvent.aspx.vb:293

      EventPlanning.WebForm2.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\EventPlanning\AddEvent.aspx.vb:100

      System.Web.UI.Control.OnLoad(EventArgs e) +67

      System.Web.UI.Control.LoadRecursive() +29

      System.Web.UI.Page.ProcessRequestMain() +724

Version Information: Microsoft .NET Framework Version:1.0.3705.209; ASP.NET
Version:1.0.3705.0



Relevant Pages

  • Re: Loading mulitple files
    ... Afterwards I pull all the xml files to a ... dim logXML, logPath, logfile, logtext, arrLogs, arrText ... set att = logXML.createAttribute ... Set oApps = oXMLDoc.DocumentElement.SelectNodes ...
    (microsoft.public.scripting.vbscript)
  • Re: Loading mulitple files
    ... Afterwards I pull all the xml files to a ... dim logXML, logPath, logfile, logtext, arrLogs, arrText ... : set att = logXML.createAttribute ...
    (microsoft.public.scripting.vbscript)
  • xml 2 sql
    ... Ok here is what I am trying to accomplish I have 12 xml files that I want to ... Dim aXMLFiles As Array ... Step 3 Connect to the sqlce database ... Dim SqlCeEngine As SqlCeEngine ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Importing XML into SQL using DTS
    ... >I need to import large XML files into an SQL table. ... > Dim objXMLDOM ... > Dim objADORS ...
    (microsoft.public.sqlserver.xml)