From 60b4db7cbbffa8f1cae6cd8edd2f134d41ce215b Mon Sep 17 00:00:00 2001 From: loudej Date: Mon, 25 Jan 2010 06:58:37 +0000 Subject: [PATCH] Initial placeholder http context to be used in background tasks --HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4045949 --- src/Orchard/Mvc/MvcModule.cs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Orchard/Mvc/MvcModule.cs b/src/Orchard/Mvc/MvcModule.cs index 7ea7a9de9..2c8964b06 100644 --- a/src/Orchard/Mvc/MvcModule.cs +++ b/src/Orchard/Mvc/MvcModule.cs @@ -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() .FactoryScoped(); } + + /// + /// standin context for background tasks. + /// + class HttpContextPlaceholder : HttpContextBase { + public override HttpRequestBase Request { + get { return new HttpRequestPlaceholder(); } + } + } + + /// + /// standin context for background tasks. + /// + class HttpRequestPlaceholder : HttpRequestBase { + /// + /// anonymous identity provided for background task. + /// + public override bool IsAuthenticated { + get { return false; } + } + } } + + } \ No newline at end of file