Capturing StackOverFlowException

4

Hello,

I'm passing some problems on the server and with the application developed in MVC ...

I checked that the site was restarting the application pool alone, so I went into Event Viweer and realized that the application is experiencing StackOverFlowException in some routine (which I could not map yet).

Right, knowing that I created a log of requests to get the urls that accessed and thus try to find the cause of the problem debugging , but I could not find the main cause, because even debugging the system by localhost and pointing to the production database this StackOverFlowException does not occur. I write the log to a .txt file before entering each action (this is how I am trying to figure out the routine that is causing the problem).

I need to know a way to catch this exception and find out which portion of the system is experiencing this problem.

• The application is developed in MVC. • Use AutoMapper (I believe it has something to do, since I have to convert each object to an ViewModel / DTO and display the information on the screen). • You are allocated on an IIS server

Update 06/01/2017

I used Elmah, but it did not work the way it created log , as the pool dropped and I believe the Elmah version was stored in memory. I discovered the problem by entering a system page locally and dropping the application.

The reason for StackoverflowException was due to the fact that it uses two routing attributes in the same Controller:

[RoutePrefix("exemplo")]
[Route("{action}"]
public class TesteController : Controller 
{
    ....
}

I removed the second attribute and the problem disappeared.

The funny thing is that this configuration was already a long time before I even took over the project. I realized that it also happened in a random way, because it normally came in all the actions of this Controller.

    
asked by anonymous 10.05.2017 / 02:10

1 answer

5

A more efficient method of catching the exception (and the Stack Trace ) is using ELMAH .

Also try to publish along with the system the .pdb file, so that you have in the captured ELMAH messages the lines where errors occur within the source code.

    
10.05.2017 / 02:24