<%@ 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 NamespaceBut, 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?