mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-23 13:22:08 +08:00
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:
@@ -28,9 +28,32 @@ namespace Orchard.Mvc {
|
|||||||
|
|
||||||
moduleBuilder.RegisterModule(module);
|
moduleBuilder.RegisterModule(module);
|
||||||
moduleBuilder
|
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>()
|
.As<HttpContextBase>()
|
||||||
.FactoryScoped();
|
.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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user