Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Major mixup in two ASP.NET transactions
Message
From
02/09/2006 16:53:07
 
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01150471
Message ID:
01150552
Views:
30
>Yes. When Page_Load fires there's no quarantee that the application level BeginReguest() hasn't already reassigned LXFramework.oRequest to a new request.

Thanks

>You'd still need
>
>      LXFramework.oRequest = Request
>      LXFramework.oResponse = Response
>
>
>My point is that these properties would need to be reset *every time* prior to referencing the LXFramework object. And I'm not even sure that would be reliable without some thread safety mechanism....

What do you think of this adjustment in the global.asax?
<%@ Application Language="VB" %>

<object id="LXFrameworkGlobal" runat="server" class="Framework.Framework.App" scope="Application" />

<script runat=server>
    Private LXFramework As Framework.Framework.App = LXFrameworkGlobal
    
    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
        LXFrameworkGlobal.nApplicationMode = 3
        LXFrameworkGlobal.oServer = Server
        LXFrameworkGlobal.Initialize()
    End Sub

    Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
        LXFramework.oRequest = Request
        LXFramework.oResponse = Response
        LXFramework.oServer = Server
        LXFramework.BeginRequest()
    End Sub
    
    Sub Application_EndRequest(ByVal sender As Object, ByVal e As EventArgs)
        LXFramework.EndRequest()
        LXFramework.oResponse.Write(LXFramework.GetJavascriptMessage)
    End Sub

    Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
        LXFramework.ErrorSetup()
    End Sub

    Sub Application_PreRequestHandlerExecute(ByVal sender As Object, ByVal e As EventArgs)
        Dim loContext As Object = Context.Handler
        Dim loType As Object = loContext.GetType()
        Dim lcType As String = loType.ToString

        ' .vb and .config not accepted
        If lcType = "System.Web.HttpForbiddenHandler" Then
            Response.Redirect("Default.aspx")
        End If
        
        Dim loPage As System.Web.UI.Page = Context.Handler
        LXFramework.oPage = loPage
    End Sub
   
</script>
Basically, on the first hit a global application object is now instantiated under the name LXFrameworkGlobal. Also, on the first hit, the event Application_Start() will make use of it.

But, on all other hits, I am creating a private property of that global application object and use that instead. As this is private, this could work. What do you think?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform