-3

I do not know where this exception is being thrown. I intercept the exception in Application_Error. Application_Error is called after the page is fully loaded. It occurs on any page.

Code of Application_Error:

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);
                }
}

Captured with error Server.GetLastError():

"Input string was not in a correct format "

Stack Trace:

 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)
  • What are the values of `logId` and `errorMessage`? –  Sep 07 '15 at 22:49
  • Try to add `~` before `/FrontEnd/` and check `logId`, `errorMessage` – Roman Marusyk Sep 07 '15 at 22:49
  • The error does not occur in Application_Error. This code is ok. I just intercept the error in this method. The problem is that this error occurs somewhere in the system, and even debugging I can not find the exact location. It can be a String.Format somewhere. I thought it might be in layout.cshtml because happen on any page. –  Sep 07 '15 at 23:04
  • Stack Trace not show my code. This is not common. –  Sep 07 '15 at 23:09
  • 2
    You can put a break point in Application_Error and try to find out offending URL and then debug that specific view or partial view. Something like : http://technobird.blogspot.com.au/2010/09/file-not-found-exception-in.html . This is not specific to your error but you will get the idea, – Hakunamatata Sep 07 '15 at 23:24
  • As I put the question and explained in the commentary, the Application_Error method, which is the only place that I capture the error. I expected that the stack trace was possible that someone has been through this and know how to answer. Scoring negative, just because you can not answer does not help me. –  Sep 07 '15 at 23:25
  • 1
    Have you ever heard about [CallStack](https://msdn.microsoft.com/en-us/library/a3694ts5.aspx)? – Roman Marusyk Sep 07 '15 at 23:28
  • No, what is CallStack? –  Sep 07 '15 at 23:30
  • Special for you there is a link (blue text). And the problem in your question but not in our answers. – Roman Marusyk Sep 07 '15 at 23:31
  • Show me how to use the "CallStack" within Application_Error using Server.GetLastError (). :P –  Sep 07 '15 at 23:39
  • Hakunamatata, Your awnser was useful. The ((HttpApplication)sender).Context.Request.Url return this -> h t t p : / / localhost:5757/__browserLink/requestData/1bc6f5af4c4e421fbed35fefb631474a –  Sep 07 '15 at 23:43

1 Answers1

-1

With the tip of Hakunamatata I saw that the problem was browserlink. In the MSDN blog(Link of blog) It has the full explanation of the browserlink. I could solve the problem with the configuration below.

  <appSettings>
    <add key="vs:EnableBrowserLink" value="false"/>
  </appSettings>