I need to run the HttpContext.Current.Server.Execute method in my ASP.NET application. This application has a WCF operation that does some processing. Currently, I am to do my processing correctly from within my WCF operation. However, I would like to do this asynchronously.
In an error to attempt this asynchronously, I tried running Server.Execute in the DoWork event handler of a BackgroundWorker. Unfortunately, this throws an error that says
"object reference not set to an instance of an object"
The HttpContext element is not null. I checked that. It is some property nested in the HttpContext object that appears to be null. However, I have not been able to identif开发者_运维技巧y why this won't work. It happens as soon as I move the processing to the BackgroundWorker thread.
My question is, how can I asynchronously execute the Server.Execute method?
Thank you,
You're doing something horribly wrong. You should not be calling Server.Execute
from your WCF service. In fact, it seems like you don't know the correct way to do asynchronous processing in an ASP.NET application. It's quite different from a desktop application.
See "Asynchronous Pages in ASP.NET 2.0" for a great article that's still relevant.
精彩评论