Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Major mixup in two ASP.NET transactions
Message
From
03/09/2006 22:53:52
 
 
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:
01150644
Views:
47
>No simple fix for these. Maybe you should store the items that aren't Request/Response related in the Context.Items collection rather than as framework properties. It would mean fairly substantial changes to your existing code but I see no obvious alternative.

I found something simple.

First of all, the global.asax now only contains this:
<%@ Application Language="VB" %>

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

<script runat=server>
    
    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
        LXFramework.nApplicationMode = 3
        LXFramework.oServer = Server
        LXFramework.Initialize()
    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
        
    End Sub
   
</script>
Secondly, all the ASPX pages inherits from the WebForm class of the framework like this:
<%@ Page Language="VB" AutoEventWireup="false" Inherits="Framework.Framework.WebForm" %>
Then, the Web Form class is having everything it needs to instantiate the framework and make it available at the page level. Then, from the page level, I can then use a reference to oApp to start things up:
Namespace Framework

    Public Class WebForm
        Inherits System.Web.UI.Page

        Public oApp As Framework.App = New Framework.App()

        Sub New()
        End Sub

        Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            oApp.nApplicationMode = 3
            oApp.oServer = Server
            oApp.Initialize()
            oApp.oRequest = Request
            oApp.oResponse = Response
            oApp.oPage = Me
            oApp.BeginRequest()
        End Sub

        Sub Page_UnLoad(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Unload
            oApp.EndRequest()
            oApp.oResponse.Write(oApp.GetJavascriptMessage)
        End Sub

    End Class

End Namespace
<script runat="server">
    Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim loDataEntry As DataEntryPurchase = New DataEntryPurchase(oApp)
        loDataEntry.GenerateForm()
    End Sub
</script>
This works and it responds fast. However, I want it to be faster. The next goal would be to get a reference to the global.asax LXFramework object in the WebForm class so I would be able to have the class like this which the initialization to the framework would be removed because I would be able to get a referenced copy of LXFramework from global.asax.
Namespace Framework

    Public Class WebForm
        Inherits System.Web.UI.Page

        Public oApp As Framework.App = New Framework.App()

        Sub New()
        End Sub

        Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init

            ' This is the line which need to be updated so I could get a reference to the global.asax framework object
            oApp=LXFramework

            oApp.oRequest = Request
            oApp.oResponse = Response
            oApp.oServer = Server
            oApp.oPage = Me
            oApp.BeginRequest()
        End Sub

        Sub Page_UnLoad(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Unload
            oApp.EndRequest()
            oApp.oResponse.Write(oApp.GetJavascriptMessage)
        End Sub

    End Class

End Namespace
But, this is the part that is missing. I don't know if it is possible to get a reference to a global.asax object from a class. Is the current context able to help me in this case?
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