I am using a backhround worker class in my generic handler code.
Here is my handler :
public void ProcessRequest(HttpContext context)
{
BackgroundWorker.Run(() =>
{
// Do work here
//If I call the static method I get an excpetion
var applicationpath =Helper.GetApplicationPath(context)
});
}
I have this method to get the current domain ?
public static string GetApplicationPath(HttpContext context)
{
var request = context.Request;
return request.Url.Scheme + System.Uri.SchemeDelimiter + request.Url.Host + (request.Url.IsDefaultPort ? "" : ":" + request.Url.Port) +
(request.ApplicationPath == "/" ? "" : request.ApplicationPath);
}
Here is the exception log
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at System.Web.Hosting.IIS7WorkerRequest.GetServerVariableInternal(String name)
at System.Web.HttpRequest.BuildUrl(Func`1 pathAccessor)
at System.Web.HttpRequest.get_Url()
at Helpers.Helper.GetApplicationPath(HttpContext context)
Is the context object lose data in background worker class ?