Difference between server.createObject and createobject in asp classic

according to

http://msdn.microsoft.com/en-us/library/ms524620.aspx

you should use server.createObject

If you are already familiar with VBScript or JScript, note that you are not using the scripting language function to create a new instance of the object (CreateObject in VBScript or New in JScript). You must use the ASP Server.CreateObject method; otherwise, ASP cannot track your use of the object in your scripts.

but some other people think that server.createObject involves an overhead that in most cases could have been avoided

http://classicasp.aspfaq.com/components/should-i-use-createobject-or-server-createobject.html

CreateObject has less overhead than Server.CreateObject, since the latter uses MTS, which leads to significant overhead.

You also suffered from performance when the component detects errors, because with Server.CreateObject these errors are written to the event log (which admittedly can be useful for debugging).

or

http://www.4guysfromrolla.com/webtech/043099-1.shtml

This can become significant if you write a component that deals with transactions, as it would be a good security network for transmission through MTS, because you will use MTS commands. However, if you are not using MTS, you can create a processor and memory on the head by passing it through Server.CreateObject. This allows you to make better use of CreateObject because it runs straight.

so if I don't use mts and don't need access to the builtins asp objects (for example, set d = createObject ("scripting.dictionary")), is it okay just to forget about server.createObject and go with createobject) ???

Thank you very much...

+4
source share
3 answers

The articles you cite are somewhat outdated. Because IIS 5 and COM + on Windows 2000 and later using Direct CreateObject are pretty much the same as using Server.CreateObject .

The behavior of MTS / COM + either CreateObject or Server.CreateObject now the same thing, partly because ASP itself works as a COM + application. You can specify that the ASP page starts the transaction, and then using CreateObject any object that implements IObjectContext will be invited to join the transaction, etc.

The only real difference that I know of is the obsolete thing when the created COM object can have an OnStartPage and an OnEndPage method. Using Server.CreateObject , these methods are called when the object is created and shortly before the object is released. This does not happen with CreateObject .

+9
source

In short, yes, that's fine. Just as Ryna S says, if you read the whole last article:

"I hope you now understand the difference when you use them."

The situation you described will be a good time, just use CreateObject and not Server.CreateObject.

This will not really matter if you really are not trying to squeeze every last ounce from the server. It should be fast enough anyway.

+2
source

The advantage of using createobject is that you can either test or reuse the libraries using simple cscript.exe. Just separate the <%%> tags.

-2
source

All Articles