static T TestAuthorization <T>(bool?allow, bool isLocalRequest, Func <HttpContextBase, IHttpHandler, T> resultor) { var mocks = new { Context = new Mock <HttpContextBase> { DefaultValue = DefaultValue.Mock }, Response = new Mock <HttpResponseBase> { DefaultValue = DefaultValue.Mock }, }; using (var app = allow == null ? new HttpApplication() : new Application { AuthorizationHandler = _ => allow.Value }) { mocks.Context.Setup(c => c.ApplicationInstance).Returns(app); mocks.Context.Setup(c => c.Request.PathInfo).Returns("/"); mocks.Context.Setup(c => c.Request.IsLocal).Returns(isLocalRequest); mocks.Response.SetupAllProperties(); mocks.Context.Setup(c => c.Response).Returns(mocks.Response.Object); mocks.Context.Setup(c => c.Items).Returns(new Hashtable()); var context = mocks.Context.Object; var factory = new ErrorLogPageFactory(); var handler = factory.GetHandler(context, null, null, null); return(resultor(context, handler)); } }
public override void ExecuteResult(ControllerContext context) { if (context == null) { throw new ArgumentNullException("context"); } var factory = new ErrorLogPageFactory(); if (!string.IsNullOrEmpty(this.resouceType)) { var pathInfo = "/" + this.resouceType; context.HttpContext.RewritePath(this.FilePath(context), pathInfo, context.HttpContext.Request.QueryString.ToString()); } var currentContext = GetCurrentContextAsHttpContext(context); var httpHandler = factory.GetHandler(currentContext, null, null, null); var httpAsyncHandler = httpHandler as IHttpAsyncHandler; if (httpAsyncHandler != null) { httpAsyncHandler.BeginProcessRequest(currentContext, r => { }, null); return; } httpHandler.ProcessRequest(currentContext); }
public override void ExecuteResult(ControllerContext context) { var factory = new ErrorLogPageFactory(); if (!string.IsNullOrEmpty(_resouceType)) { var pathInfo = "/" + _resouceType; context.HttpContext.RewritePath(FilePath(context), pathInfo, context.HttpContext.Request.QueryString.ToString()); } var currentContext = GetCurrentContext(context); var httpHandler = factory.GetHandler(currentContext, null, null, null); if (httpHandler is IHttpAsyncHandler httpAsyncHandler) { httpAsyncHandler.BeginProcessRequest(currentContext, r => { }, null); return; } httpHandler.ProcessRequest(currentContext); }
public override void ExecuteResult(ControllerContext context) { var factory = new ErrorLogPageFactory(); if (!string.IsNullOrEmpty(_resouceType)) { var pathInfo = "/" + _resouceType; context.HttpContext.RewritePath(FilePath(context), pathInfo, context.HttpContext.Request.QueryString.ToString()); } var currentContext = GetCurrentContext(context); var httpHandler = factory.GetHandler(currentContext, null, null, null); var httpAsyncHandler = httpHandler as IHttpAsyncHandler; if (httpAsyncHandler != null) { httpAsyncHandler.BeginProcessRequest(currentContext, r => { }, null); return; } httpHandler.ProcessRequest(currentContext); }