我一直在寻找这个问题的答案。我在Google上找到了一些网站,谷歌在示例文本中列出了我的错误,但发现页面中实际上并不存在相同的文本(这种情况多次发生),或者结果却是一个不同的问题(很简单)修复这对我不起作用)。
我在ASP.NET Web表单项目(v3.5)中使用Elmah。 Elmah工作得很好,并且成功记录(在SQL数据库中)。在Global类中,我在Logged事件处理程序中捕获ErrorID并在自定义类中调用几个方法。
protected void errorLog_Logged(object sender, ErrorLoggedEventArgs e)
{
ElmahLogManager logMgr = new ElmahLogManager(e.Entry, HttpContext.Current);
logMgr.LogErrorDetails();
string errorPageUrl = logMgr.GetErrorPageUrl();
if (!string.IsNullOrEmpty(errorPageUrl))
{
Response.Redirect(errorPageUrl);
}
}
供您参考,第一种方法(LogErrorDetails)记录额外的细节,如会话变量,第二种方法(GetErrorPageUrl)返回带有ErrorID作为参数的url。这两种方法都有效。正在记录会话数据,并返回url(例如:“ErrorPage.aspx?id = DB9AFF21-A614-446E-8FF1-E35CFBE56C57”)。
我遇到的问题是当重定向发生时,抛出一个System.Web.HttpException当然会记录一个新的错误,再次引发这个事件,并且整个事情一遍又一遍地发生,直到系统说它已经足够退出循环。
我得到的具体错误是:
解析属性'title'时出错:'title'属性是只读的,无法设置。
永远不会到达错误页面(即永远不会到达Page_Load或OnInit开头的断点)。
堆栈跟踪没有显示任何有用的东西(对我来说),但如果它对你有用,这里是:
System.Web.HttpParseException: Error parsing attribute 'title': The 'title' property is read-only and cannot be set.
---> System.Web.HttpParseException: Error parsing attribute 'title': The 'title' property is read-only and cannot be set.
---> System.Web.HttpException: Error parsing attribute 'title': The 'title' property is read-only and cannot be set.
at System.Web.UI.TemplateParser.ProcessError(String message)
at System.Web.UI.TemplateControlParser.ProcessUnknownMainDirectiveAttribute(String filter, String attribName, String value)
at System.Web.UI.PageParser.ProcessUnknownMainDirectiveAttribute(String filter, String attribName, String value)
at System.Web.UI.TemplateParser.ProcessMainDirective(IDictionary mainDirective)
at System.Web.UI.TemplateControlParser.ProcessMainDirective(IDictionary mainDirective)
at System.Web.UI.TemplateParser.ProcessDirective(String directiveName, IDictionary directive)
at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
--- End of inner exception stack trace ---
at System.Web.UI.TemplateParser.ProcessException(Exception ex)
at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
--- End of inner exception stack trace ---
at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath)
at System.Web.UI.TemplateParser.ParseInternal()
at System.Web.UI.TemplateParser.Parse()
at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType()
at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider)
at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
有没有人对如何解决这个问题有任何想法?