Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Major mixup in two ASP.NET transactions
Message
From
04/09/2006 11:55:03
 
 
To
04/09/2006 11:48:27
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:
01150719
Views:
54
>>One way is to get a reference from the StaticObjects collection. C# version:
>>
>>        Framework.App oApp = (Framework.App )Application.StaticObjects.GetObject("LXFramework"");
>>
>
>Thanks
>
>>but I fail to see how the code in Page_Init above differs in any real sense to the original code that you had in BeginRequest. You're back to passing a reference into a global object that cannot be quaranteed to be correct when accessed later. You have exactly the same predicament as in the original. Consider just these four lines of code
>>
>>>            oApp.oRequest = Request
>>>            oApp.oResponse = Response
>>>            oApp.oServer = Server
>>>            oApp.oPage = Me
>>>            oApp.BeginRequest()
>>
>>By the time BeginRequest() is entered oApp.oRequest could already be invalid!
>>To recap: you *cannot* safely access hit dependent data from within the application scoped framework object except via the current context.
>
>Well, lets verify something first. The actual code is this:
>
>
>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
>
>
>In this actual code, I am creating an application object for every hit and that is done at the page level. So, I cannot see how this could conflict with another instance. This application object is created at every hit in the page. Into that application object, I am referencing the page Request and Response object. I don't see how this could fail. This seems to be independent per page.

That code is fine - you're creating a new Framework object for every hit. But then you said that, to avoid the initialisation overhead you wanted to use:
  oApp=LXFramework
where LXFramework was the global framework object. That's where you'd have the problem.
Regards,
Viv
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform