[This is preliminary documentation and subject to change.]
Using ASP, it is easy to take advantage of the reliability provided by MTS services. You only need to include the @TRANSACTION directive in your script. This directive tells MTS that any changes that occur in that page, such as database manipulation or MSMQ message transmission, should be considered transactions. A change that is being managed by transaction services can be either committed, making it more or less permanent, or aborted, which would result in the state of the database or queue being rolled back to before the changes were made.
In this sample, the entire page has been declared a transaction, as described above. The sample then provides some scripting commands for two other procedures that are called to perform additional completion or clean-up tasks. OnTransactionCommit is called when either the script has sucessfully completed, or the ObjectContext.SetComplete method has been called. Likewise, OnTransactionAbort is called when the script either encounters some kind of processing error, or the ObjectContext.SetAbort method has been called.
This sample commits, by default, because it simply prints a small message and then exits. Since the directive declared the script to be a transaction, exiting sucessfully automatically commits changes made in the script, of which there are none, and triggers the OnTransactionCommit procedure, which prints a message.
For a sample that always aborts, see the sample Forced Abort.
Note The @TRANSACTION directive must be on the first line of the .asp file, or an error will be generated.