Initial placeholder http context to be used in background tasks

--HG--
extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4045949
This commit is contained in:
loudej
2010-01-25 06:58:37 +00:00
parent ac6e2a5961
commit 60b4db7cbb

View File

@@ -28,9 +28,32 @@ namespace Orchard.Mvc {
moduleBuilder.RegisterModule(module);
moduleBuilder
.Register(ctx => HttpContext.Current == null ? null : new HttpContextWrapper(HttpContext.Current))
.Register(ctx => HttpContext.Current == null ? (HttpContextBase)new HttpContextPlaceholder() : new HttpContextWrapper(HttpContext.Current))
.As<HttpContextBase>()
.FactoryScoped();
}
/// <summary>
/// standin context for background tasks.
/// </summary>
class HttpContextPlaceholder : HttpContextBase {
public override HttpRequestBase Request {
get { return new HttpRequestPlaceholder(); }
}
}
/// <summary>
/// standin context for background tasks.
/// </summary>
class HttpRequestPlaceholder : HttpRequestBase {
/// <summary>
/// anonymous identity provided for background task.
/// </summary>
public override bool IsAuthenticated {
get { return false; }
}
}
}
}