httpModule stops WebResource.axd from working correctly

Rouchie

New member
Joined
Aug 15, 2006
Messages
2
Location
North Yorkshire, England
Programming Experience
1-3
I have a httpModule that's supposed to check for a session value before sending the page contents to the user. If the session value doesn't exist, it redirects the user to a login page.

The problem is that this module is somehow preventing WebResource.axd from working. When the module is enabled, the browser fails to read the javascript within the webresource.axd and throws javascript errors, especially on pages where asp:validators are present.

Can anyone see what might be causing this based on the module's code...?
VB.NET:
    Public Class checkSession
        Implements IHttpModule

        Public Sub New()
        End Sub

        Public Sub Init(ByVal ctx As HttpApplication) Implements System.Web.IHttpModule.Init
            AddHandler ctx.PostAcquireRequestState, AddressOf context_PostAcquireRequestState
        End Sub

        Public Sub Dispose() Implements System.Web.IHttpModule.Dispose
        End Sub

        Private Sub context_PostAcquireRequestState(ByVal sender As Object, ByVal e As EventArgs)
            Dim ctx As HttpContext = HttpContext.Current
            Dim session As HttpSessionState = ctx.Session
            If Not ctx.Request.RawUrl.Contains("login.aspx") Then
                If session("ID") Is Nothing Then
                    ctx.Response.Redirect("login.aspx", True)
                End If
            End If
        End Sub

    End Class
 
I'm not entirely sure, but I think I might have solved it - although not sure yet...

If I force the URL to lower and also reference webresource.axd in the module check, then it seems to work:

VB.NET:
If Not ctx.Request.RawUrl.ToLower.Contains("login.aspx") AndAlso Not ctx.Request.RawUrl.ToLower.Contains("webresource.axd") Then
                If session("customerID") Is Nothing Then
                    ctx.Response.Redirect("login.aspx", True)
                End If
End If
 
Back
Top