Forms Authentication/xml dom/http handler

From: andy@nospam.com
Date: 01/29/03


From: <andy@nospam.com>
Date: Wed, 29 Jan 2003 16:56:57 -0000


Hi,

I have a webform which loads an xml document via the dom. The web app uses
forms authentication. I do not want the xml file (which resides within the
app) to be accessible directly via an http request unless prompted for
authentication.

So I have been trying to write an HTTP handler for xml files. This works by
asking for authentication when requesting the xml file directly but now the
web form fails when loading the xml file into the dom with the error: This
is an unexpected token. Expected 'WHITESPACE'.

Removing the httphandler from the equation allows the web form to work
again, but the xml is then unprotected.

Web Form:
Dim reader As XmlTextReader
reader = New XmlTextReader(http://www.mydomain/aFile.xml)
xmlDoc = New XmlDocument()
xmlDoc.Load(reader) <== Fails here

HTTPhandler:
    Public Class xmlHandler
        Implements IHttpHandler

        Public Sub ProcessRequest(ByVal context As HttpContext) Implements
IHttpHandler.ProcessRequest

            context.Response.Buffer = True
            context.Response.Clear()

            context.Response.AddHeader("content-disposition",
"attachement;")
            context.Response.ContentType = "text/xml"

context.Response.WriteFile(context.Request.ServerVariables("PATH_INFO"))

        End Sub

        ' Override the IsReusable property.
        Public ReadOnly Property IsReusable() As Boolean Implements
IHttpHandler.IsReusable
            Get
                Return True
            End Get
        End Property

    End Class

The HTTPhandler is directly ripped from an example
(http://tiberi.us/view_article.aspx?article_id=31)

I have a feeling that it has something to do with loading the xml file into
the dom through the handler... but cannot be sure of that.
Any help/pointers (idiots guide to httphandlers) much appreciated.

Thanks
Andy

PS. the xml is well formed.



Relevant Pages