public static Task WebDefaultHanlder(HttpContext context) { WebDefaultXmlConfig defaultConfig = WebGlobalVariable.WebCurrent.WebDefaultValue; IDefaultHandler handler = defaultConfig.DefaultHandler?.CreateObject() ?? EmptyDefaultHandlerConfig.Hanlder; return(handler.Process(context)); }
private static Task ProcessException(HttpContext context, WebDefaultXmlConfig defaultConfig, WebBasePage page, PageSourceInfo info, Exception exception) { if (exception is RedirectException redirectEx) { context.Response.Redirect(redirectEx.Url.ToString(), false); return(Task.FromResult(0)); } else if (exception is ReLogOnException) { return(HandleException(defaultConfig.ReLogOnHandler, GetWebHandler(page, context, info), page, exception)); } else if (exception is ErrorPageException) { return(HandleException(defaultConfig.ErrorPageHandler, GetWebHandler(page, context, info), page, exception)); } else if (exception is ErrorOperationException) { return(HandleException(defaultConfig.ErrorOperationHandler, GetWebHandler(page, context, info), page, exception)); } else if (exception is ToolkitException) { return(HandleException(defaultConfig.ToolkitHandler, GetWebHandler(page, context, info), page, exception)); } else { return(HandleException(defaultConfig.ExceptionHandler, GetWebHandler(page, context, info), page, exception)); } }
//private ExceptionIndexer fExceptionIndexer; internal WebGlobalVariable() { fCurrent = this; Current = this; NeitherContext = true; WebDefaultValue = new WebDefaultXmlConfig(); DefaultValue = WebDefaultValue; }
public static void Config(this WebAppSetting setting, WebDefaultXmlConfig extXml) { WebConfigItem defaultConfig = extXml?.WebConfig; setting.DefaultPageMaker = defaultConfig?.DefaultPageMaker ?? new SourceOutputPageMakerConfig(); setting.DefaultRedirector = defaultConfig?.DefaultRedirector ?? new OutputRedirectorConfig(); setting.DefaultPostCreator = defaultConfig?.DefaultPostObjectCreator ?? new JsonPostDataSetCreatorConfig(); setting.ReadSettings = defaultConfig?.ReadSettings ?? ReadSettings.Default; setting.WriteSettings = defaultConfig?.WriteSettings ?? WriteSettings.Default; //ExceptionHandlerConfigItem exConfig = extXml.ExceptionHandler; //if (exConfig != null) //{ // //ErrorPageHandler = exConfig.ErrorPageException; // //ErrorOpeartionHandler = exConfig.ErrorOperationException; // //ReLogOnHandler = exConfig.ReLogonException; // //ToolkitHandler = exConfig.ToolkitException; // //ExceptionHandler = exConfig.Exception; //} //var tempHandleConfig = new PageMakerExceptionHandlerConfig() //{ // PageMaker = new TempPageMakerConfig(ExceptionPageMaker.Instance) //}; //if (ErrorPageHandler == null) // ErrorPageHandler = tempHandleConfig; //if (ErrorOpeartionHandler == null) //{ // ErrorOpeartionHandler = tempHandleConfig; //} //if (ReLogOnHandler == null) // ReLogOnHandler = new ReLogonExceptionHandlerConfig(); //if (ToolkitHandler == null) // ToolkitHandler = tempHandleConfig; //if (ExceptionHandler == null) // ExceptionHandler = new PageMakerExceptionHandlerConfig() // { // Log = true, // PageMaker = new TempPageMakerConfig(ExceptionPageMaker.Instance) // }; }
public Task ProcessRequest(HttpContext context, RequestDelegate next, PathStringParser parser) { PageSourceInfo info = null; parser.Parse((input) => { info = ParseUrl(input, info); }); if (info == null) { return(null); } context.Items[WebUtil.SOURCE_INFO] = info; WebDefaultXmlConfig defaultConfig = WebGlobalVariable.WebCurrent.WebDefaultValue; WebBasePage page = null; try { if (info.IsContent) { page = new WebModuleContentPage(context, next, info); } else { page = new WebModuleRedirectPage(context, next, info); } return(page.LoadPage()); } catch (RedirectException ex) { context.Response.Redirect(ex.Url.ToString(), false); return(Task.FromResult(0)); } catch (ReLogOnException ex) { return(HandleException(defaultConfig.ReLogOnHandler, GetWebHandler(page, context, info), page, ex)); } catch (ErrorPageException ex) { return(HandleException(defaultConfig.ErrorPageHandler, GetWebHandler(page, context, info), page, ex)); } catch (ErrorOperationException ex) { return(HandleException(defaultConfig.ErrorOperationHandler, GetWebHandler(page, context, info), page, ex)); } catch (ToolkitException ex) { return(HandleException(defaultConfig.ToolkitHandler, GetWebHandler(page, context, info), page, ex)); } catch (Exception ex) { Exception innerEx = ex.InnerException; if (innerEx != null) { return(ProcessException(context, defaultConfig, page, info, innerEx)); } else { return(ProcessException(context, defaultConfig, page, info, ex)); } } }