Question
How do I store objects in session/application scope?

Answers

Please don't.
Many people seem tempted to store objects in the session, so that they don't have to create instances on each
page. This is particularly true for connection objects and recordsets.
They assume this is more efficient, but it is not. This is the absolute worst use of resources you can have
(particularly with ADO objects) and will significantly reduce your application's scalability. See these articles for
more details:
KB #258939 Recommendations for Connecting to Databases Through IIS
http://www.microsoft.com/mind/1198/ado/ado.htm (tip #6)
KB #176056 INFO: ADO/ASP Scalability FAQ
Here are some other KB articles that should help clarify the issues at hand (I hope you didn't expect this to be light
reading):
KB #243544 INFO: Component Threading Model Summary Under Active Server Page
KB #191979 PRB: VB Component Not Marked Apartment Produces ASP 0115 Error
KB #243548 Design Guidelines for VB Components Under ASP
KB #243543 Single-Threaded Apartment Objects in Session or Application
Also, some gratuitous stuff from Charles Carroll:
Session Overview & Myths
Databases & Sessions... Just Say No!
Global.asa Overkill
Another possible outcome of storing an improperly threaded object in session or application scope is the following:
error '8001010E'
The application called an interface that was marshalled for a different thread.
Make sure that your object is explicitly written for this scope before you attempt to utilize it this way. (Hint: no VB6
object is threaded correctly for use in session / application scope.)
Note that it is possible to safely store a recordset in the session, by first converting it to its array form using
GetRows(). See Article #2467 for an article on using GetRows().
There is at least one exception to this 'rule' - it is acceptable to store the free-threaded version of the MSXML DOM
Document object in application scope, for example:

<%
Set DOM = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
DOM.loadXML ""
Set Application("DOM") = DOM
%>
  Your Comment




More Software Questions..
What is the inputsplit in map reduce software?

What is software configuration management?

What Is Java Api For Xml-based Rpc (jax-rpc)?

How can you implement fine-grained auditing?

What is IBM’s simple explanation for Big Data’s four critical features?

What is static synchronized method in JDBC API? Give an example?

What does the NULLIF function do?

What happens if a start method is not invoked and the run method is directly invoked?

Should we override finalize method

what is the difference between mysql_fetch_array and mysql_fetch_object?

How will XML affect my document links?

Why to use Style Sheets?

What are Filters in MVC?

Can you explain Application layer in OSI model?

How to define new testplan attributes?

What are the minimum system requirements to run Photoshop? Is it possible to run Photoshop over linux?

Which oracle package is used to manage the oracle lock management services?

What is Latch Up? Explain Latch Up with cross section of a CMOS Inverter. How do you avoid Latch Up?

What is marker interface?

What types of partitioning are there for BW?



Search
Can you Answer!!
  • Q Union minister of Mine & steel, labour & employment
  • Q What is scala tympani
  • Q Who wrote The Last Picture Show
  • Q Deposit Insurance credit guarantee corporation was established in the year _____:
  • Q A colony of Britain until 1956, with the capital city of Khartoum, the south of what African country became an independent state in July 2011?
  • Q Explain what are sqlite indexes?
  • Q What are the various options that exist in terms of money?
  • Q What is crm technology?
  • Q Which one of the following is known as the brown coal?
  • Q Can you have VBX and OCX controls in forms ?
  • Q Which property specifies an image rather than a bullet point or number for the marker of a list