IBM Computer, Laptops and Servers

Back Homepage Content Directory Resource Guide Blog

Should I use CreateObject or Server.CreateObject?

Most of my code uses CreateObject, rather than Server.CreateObject. I used to have a strong opinion that Server.CreateObject was somehow better, but in most cases, I no longer believe that.

CreateObject has less overhead than Server.CreateObject, because the latter uses MTS causing significant overhead.

You will also suffer performance hits when the component encounters errors, because with Server.CreateObject, these errors are written to the event log (which, admittedly, can be useful during debugging).

You cannot use Server.CreateObject when accessing a component through a firewall. See KB #193230 for more information.

However, keep in mind that there are cases where you actually need to use Server.CreateObject.

If you are using and relying on MTS to handle transactions in your application, you cannot do this with CreateObject.

If you are using a custom or 3rd party component, such as ASPUpload, that uses the ASP intrinsic objects (Server, Request, Response, Application, Session, ASPError, ObjectContext), CreateObject alone does not provide the component with access to these objects.

If you have a legacy component that relies on the onStartPage and onEndPage methods, their firing cannot be relied upon with CreateObject alone.

Note that I use VBScript for just about all of my ASP code. If you are using JScript or JavaScript as your server-side language, the Server. prefix is not optional. See Article #2382 for details.

[ Comment, Edit or Article Submission ]

Share this:

Add To Yahoo MyWeb Add To Google Bookmarks Add To Furl Fav This With Technorati Add To Newsvine Add To Bloglines Add To Ask Add To Windows Live Add To Slashdot Stumble This Digg This Add To Del.icio.us Add To Reddit

More about:

Nov December 2008 Jan
Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      

IBM Computer, Laptops and Servers Blog on Technorati Related Blog of IBM Computer, Laptops and Servers on Sphere
Content Directory
Resource Guide


MDS Battery Shop for All Battery and Power Needs

Website Links
IBM Computer, Laptops and Servers Copyright © 2008 www.ibmfans.com. All rights reserved. Site Map
Homepage | Blog | Advertise | Privacy Policy | Disclaimer | Contact Us | Links