/// <summary> /// /// </summary> /// <param name="context"></param> /// <returns></returns> public static IHttpHandler TryGetHttp404PageHandler(HttpContext context) { // 当诊断模式启用时,优先选择直接返回Http404PageHandler的方式,避免进入错误解析模式。 DiagnoseResult diagnoseResult = TryGetDiagnoseResult(context); if (diagnoseResult != null) { if (diagnoseResult.AssemblyList == null) { ControllerRecognizer recognizer = ObjectFactory.New <ControllerRecognizer>(); List <Assembly> list = recognizer.GetControllerAssembly(); diagnoseResult.AssemblyList = (from a in list select a.FullName).ToList(); } diagnoseResult.UrlActionInfo = context.Items[UrlActionInfo.HttpContextItemKey] as UrlActionInfo; //diagnoseResult.ErrorMessages.Add("不能根据当前URL创建请求处理器,当前URL:" + context.Request.RawUrl); return(new Http404PageHandler(diagnoseResult)); } else { return(null); } }
internal Http404PageHandler(DiagnoseResult diagnoseResult) { DiagnoseResult = diagnoseResult; }