Re: Maintaining State Between Web Pages
- From: "Joe Fawcett" <joefawcett@xxxxxxxxxxxxxxxx>
- Date: Sun, 27 Jul 2008 10:28:29 +0100
"Old Pedant" <OldPedant@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:14752B59-5E47-49D5-B702-0F8333E1DA1D@xxxxxxxxxxxxxxxx
Depends on what "between pages" means.You could also create in the global.asa. Perhaps even declare it using the object tag.
Between successive page hit BY THE SAME PERSON? That is, page hits within
the same SESSION?
Or between all page hits by all users?
If the latter, it's easy. Just use static data (shared in VB). All users
will get the same data.
But I'm guessing you mean between hits in the same session.
In which case you've got some choices.
First off, *IF* you coded your COM object using the right threading model,
you could simply store an instance of the object in a session variable.
Set myObj = Server.CreateObject("myfoo.whatever")
...
Set Session("foo") = myObj
If you used apartment threading, this is a bad idea. When the object is
needed again, it has to be instantiated in the same thread it was created in.
Can cause performance bottlenecks. Having said that, it's not a *terrible*
idea if your web site is only lightly loaded and especially if your component
is only used for (say) a fraction of a second on each page. But if you want
the best possible performance, you need to make the object "both threaded."
It's my understanding that VB6 is not capable of creating "both threaded"
COM objects, though I *believe* it can produce apartment threaded ones. You
don't say how you created your custom object, but if you did it with VB, you
are stuck.
Incidentally, you *MUST* use
Server.CreateObject
and *NOT* just
CreateObject
if you intend to save the object in a Session value, or at least that is my
own understanding.
I'm NOT an expert on this stuff. I created a grand total of two COM objects
for use with ASP, mainly just to see how it was done. Since most ISPs won't
allow you to install your own custom objects, and since all but one of the
web sites I've worked on were hosted by ISPs, it seemed pointless to use them.
--
Joe Fawcett (MVP - XML)
http://joe.fawcett.name
.
- References:
- RE: Maintaining State Between Web Pages
- From: Old Pedant
- RE: Maintaining State Between Web Pages
- Prev by Date: RE: Maintaining State Between Web Pages
- Next by Date: Re: Maintaining State Between Web Pages
- Previous by thread: RE: Maintaining State Between Web Pages
- Next by thread: RE: Maintaining State Between Web Pages
- Index(es):
Relevant Pages
|