I have a ASP.NET page with a WebMethod that creates an object and runs one of the object’s methods in a new thread.
I need to access the System.Web.HttpContext.Current.Response.ContentType property from within this thread.
Each time I (try to) access it, I receive a NullReferenceException.
Is this posible?
The
HttpContext.Currentreturns the instance for the current thread. Since you are executing in another thread, you can’t access it this way. Try to pass theContentTypeto your thread, but be careful in passing aHttpResponseobject to another thread, since it is not thread-safe.