difference between server.createObject and createobject in asp classic

别来无恙 提交于 2019-12-04 09:37:56

Those articles you are quoting are somewhat out-of-date. Since IIS 5 and COM+ on Windows 2000 and above using the straight CreateObject is pretty much the same as using Server.CreateObject.

The MTS/COM+ behaviour of either CreateObject or Server.CreateObject is now the same, this in part due to the fact that ASP itself runs as a COM+ application. You can specify that the ASP page starts a transaction and then using CreateObject any object implementing IObjectContext will be invited to join the transaction etc.

The only real difference I know of is a legacy thing where a COM object being created may have OnStartPage and a OnEndPage method. Using Server.CreateObject these methods are called when the object is created and just before the object is released. This doesn't happen with CreateObject.

In short, yes its fine. Just as Ryna S says if you read the whole of the last article:

"hope you understand the difference now, and when to use the two."

The situation you describe would be a good time just just use CreateObject rather than Server.CreateObject.

Unltimately it will not make that much of a difference unless you really are trying to squeeze every last ounce out of a server. Should be plenty fast enough either way.

The advantage of using createobject is that one can either test, or reuse libaries when using plain cscript.exe. Just strip the <% %> tags.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!