C# MVC-输入字符串格式不正确-应用程序错误-Global.asax
我不知道这个异常被抛出到哪里。 我截获应用程序错误中的异常。 页面完全加载后调用应用程序错误。 它出现在任何页面上 应用程序错误代码:C# MVC-输入字符串格式不正确-应用程序错误-Global.asax,c#,asp.net-mvc,asp.net-mvc-4,global-asax,application-error,C#,Asp.net Mvc,Asp.net Mvc 4,Global Asax,Application Error,我不知道这个异常被抛出到哪里。 我截获应用程序错误中的异常。 页面完全加载后调用应用程序错误。 它出现在任何页面上 应用程序错误代码: protected void Application_Error(object sender, EventArgs e) { string errorMessage = ""; LogServices logServ = new LogServices(); Exc
protected void Application_Error(object sender, EventArgs e)
{
string errorMessage = "";
LogServices logServ = new LogServices();
Exception exception = Server.GetLastError();
string exMsg = exception.Message;
Exception _ex = exception.InnerException;
while(null != _ex)
{
exMsg = string.Format("{0} {1}", exMsg, _ex.Message);
_ex = _ex.InnerException;
}
string logId = logServ.log(exception, "", Context.Request.UserAgent);
if (exMsg.IndexOf("was not found") != -1)
{
errorMessage = ElizeuSites.AssimEstaEscrito.Resources.Global.PageNotFound;
Server.ClearError();
string urlRedirect = String.Format("/FrontEnd/{0}/{1}?{2}={3}&errorMessage={4}", "Error", "PopUpError", "logId", logId, errorMessage);
Server.TransferRequest(urlRedirect);
}
}
已捕获错误服务器。GetLastError():
“输入字符串的格式不正确”
堆栈跟踪:
em System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args)
em System.String.Format(IFormatProvider provider, String format, Object[] args)
em Microsoft.VisualStudio.Web.PageInspector.Runtime.MappingData.MappingDataUtilities.GenerateSelectorIfUnique(List`1 elements, String selectorFormatString)
em Microsoft.VisualStudio.Web.PageInspector.Runtime.MappingData.MappingDataUtilities.GenerateSelectorsFromIds(List`1 elements, String selectorFormatString)
em Microsoft.VisualStudio.Web.PageInspector.Runtime.MappingData.MappingDataUtilities.GenerateSelectorsInternal(IEnumerable`1 elements, String selectorFormatString, Func`2 isUniqueTagName, Boolean indexAsLastResort)
em Microsoft.VisualStudio.Web.PageInspector.Runtime.MappingData.MappingDataUtilities.GenerateSelectors(IEnumerable`1 elements)
em Microsoft.VisualStudio.Web.PageInspector.Runtime.MappingData.MappingDataUtilities.ProcessDataIntoJsonObjects(IEnumerable`1 renderedOutputList)
em Microsoft.VisualStudio.Web.PageInspector.Runtime.Tracing.RequestDataHttpHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext context)
em System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
em System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
通过Hakunamatata的提示,我发现问题出在browserlink上。在MSDN博客(L)中,有对browserlink的完整解释。我可以用下面的配置解决这个问题
<appSettings>
<add key="vs:EnableBrowserLink" value="false"/>
</appSettings>
logId和errorMessage
的值是什么?尝试在/FrontEnd/
之前添加~
,并检查logId
,errorMessage
应用程序错误中不会发生错误。这个代码没问题。我只是截取了这个方法中的错误。问题是这个错误发生在系统的某个地方,甚至调试我都找不到确切的位置。它可以是一个字符串。格式在某个地方。我认为它可能在layout.cshtml中,因为它发生在任何页面上。您可以在应用程序错误中设置断点,并尝试找出有问题的URL,然后调试特定视图或部分视图。类似于:。这并不是针对你的错误,但你会明白的,你听说过吗?