Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Major mixup in two ASP.NET transactions
Message
De
03/09/2006 12:51:52
 
 
À
03/09/2006 11:13:08
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01150471
Message ID:
01150604
Vues:
26
Hi,

>
>Is the application factory the only way to achieve this? I have seen numerous examples on the net using the global.asax approach such as I did. I guess most of them never tested it in production with simultaneous hits. The goal here is to have the Initilaze() method of the framework to be initialized once. As this takes some time, and all the initialization in there, I need to make sure it will only be initialized once. Then, on upcoming hits, I need to start from that object but have to find a way to have everything from that point to be proprietary to the current hit. I guess the application factory would be the only way to achieve that. What do you think?

I've not enough knowledge to say - but I don't think it's relevant. For what it's worth I knocked up a simple version of your design as I understand it. (C# sorry). Global.asax:
< %@ Application Language="C#" % >
<object id="GO" runat="server" class="GlobalObject" scope="Application"/>
<script runat="server">
   void  Application_BeginRequest(object sender, EventArgs e)
    {
        Application.Lock();
        GO.SavedResponse = HttpContext.Current.Response;
        GO.SavedRequest = HttpContext.Current.Request;

        DataEntryPurchase dep = new DataEntryPurchase(GO);
        dep.Log("BeginRequest");
     }

    void Application_EndRequest(object sender, EventArgs e)
    {
        DataEntryPurchase dep = new DataEntryPurchase(GO);
        dep.Log("EndRequest");
        Application.UnLock();
    }
</script>
Relevant classes:
public class GlobalObject
{
    private HttpRequest _savedRequest;
    private HttpResponse _savedResponse;
    
    public HttpResponse ActualResponse
    {
        get{return HttpContext.Current.Response; }
    }

    public HttpRequest ActualRequest
    {
        get { return HttpContext.Current.Request; }
    }

    public HttpRequest SavedRequest
    {
        get { return _savedRequest; }
        set { _savedRequest = value; }
    }

    public HttpResponse SavedResponse
    {
        get { return _savedResponse; }
        set { _savedResponse = value; }
    }
}

public class DataEntryPurchase
{
    private GlobalObject oFrame;
    public DataEntryPurchase(GlobalObject o)
    {
        GO = o;
    }
    public void Log(string s)
    {
        GO.ActualResponse.Write(DateTime.Now.ToString() + ": " + s  );
        GO.ActualResponse.Write("Saved: " +oFrame.SavedRequest.RawUrl) ;
        GO.ActualResponse.Write("Actual: " + oFrame.ActualRequest.RawUrl);
    }
}
but this does force requests to be queued and processed sequentially. Whether this would give acceptable performance will depend on the level of hits the site is expected to receive (but even if acceptable it wouldn't 'feel right' to me). I tested with a couple of different aspx's with just 'System.Threading.Thread.Sleep(10000);' in the Page_Load. Removing the lock code will also demonstrate the problem you currently have..

Can I ask what other request specific info is held by your framework beyond the Reguest/Response objects ?

Regards,
Viv
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform