Debugging ASP.NET Timeout - asp.net

I need to debug an asp.net website following a timeout, i.e. via a breakpoint placed in the .aspx page that is specified as the loginURL setting in forms authentication config.
However, I understand that when debug="true" the site will not timeout (link text)
So how can I debug timeout scenarios?
Thanks.

I guess you are interested in finding out which part of the code is slow enough to cause the request to time out. If you step through it line-by-line in debug mode, you should be able to identify which line is causing the problem, even though the 'timeout' exception will not get triggered.

If time-outs are the problem, why not use the standard trace functionality in ASP.NET? Using the trace information enables you to determine where the most time is spent. This may help to identify the bottleneck.
See here for an example of tracing in ASP.NET.

re: "Thanks for the replies above, although rather than identifying what is causing the timeout, I need to actually cause a timeout and trace through code following the timeout.
A problem has been reported whereby following a timeout and logging back in to the site, some strange behaviour has been observed which I am trying to identify."
Perhaps there is no way to do this in debug mode then. Trace might be useful, or adding in lots of commands to log information to a file so you can later see what was happening.
One other thought: Are your users pressing the back button after getting the timeout error? In some situations this could lead to unexpected behaviour.

Related

Sharepoint Online ClinetContext.ExecuteQuery causes connection reset

I have an ASP.NET application hosted in IIS calling Sharepoint using ClientContext. On a production deployment, a call to ExecuteQuery causes the ASP.NET to throw net::ERR_CONNECTION_RESET. On the server, the following exception was thrown:
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
at Microsoft.SharePoint.Client.ClientRequest.<ExecuteQueryToServerAsync>d__6.MoveNext()
Cannot complete this action. Please try again.
There is no other trace of any other error, except this.
I have tried setting TLS1.2 with no success.
I have also tried using a delay before the call to ExecuteQuery and the result was still a failure.
Can anyone suggest what could be going wrong here?
Note: it works perfectly on my local machine.
After spending a few valuable hours, I found the solution. One of the fields had a wrong date time value and Sharepoint, on the flip side, without throwing a meaningful exception, just caused the request in IIS to abruptly close.

Any way to handle Ajax Errors globally on asp net webforms?

I am looking for a way to log ajax errors globally. I have already read numerous ways but none of them worked. The problem is that when an error occured in ajax requests it gets handled by the RestHandler.ExecuteWebServiceCall and never triggers Application_Error.
It is well described here by #Michael Liu .
The problem with his answer is that there is no way to get the actual exception and log it if you have customErrors option set to On in webconfig.
Note that i don't want to return stack traces to javascript or anything like that. Also the app is very old and big and i am not able to change the entire system of how soap or ajax or logging works as it would be a high risk of breaking the app.
Is there any way to catch and log these exceptions globally?
Thanks in advance.

IIS Worker process hangs forever on first request

I am working on solving a problem that I have had for a couple of days now. Every time one of my sites are rebuild or the AppPool is recycled, the first pageload will hang forever (well, I've only waited up to 30 minutes). It is only happening on one particular site out of ~10 sites. It is an ASP.NET site.
Here are the things I have observed:
In IIS Manager under worker processes I can see the request. Verb = GET, Sate = ExecuteRequestHandler, Module Name = ManagedPipelineHandler. Time Elapsed just keeps increasing, of course.
If I close down the browser in which I made the initial request and then open a new one to make another request, the page will load instantly.
In my code the Application_Start of my Global.asax file is not called on the first request. It is called on the second request.
The worker proccess is causing the memory usage on my machine to go through the roof
I'm inexperienced in troubleshooting IIS, but hours and hours of searching has led me nowhere.
The only major code change we have made on the site recently is that we have started implementing logging using log4net. I have though tried to remove any log4net code, both from my web.config file and Global.asax - still no luck.
Has anyone else experienced this and if so how did you solve it?
Any and all help will be much appreciated.
ADD:
If I place a .txt file in the root of the site and load that as the first thing after a build it will load instantly.
However the worker proccess still acts exactly as before and the memory usage still goes through the roof.
Final edit:
I feel like such an idiot. I can't explain why, but for some reason my break points in Global.asax suddenly got hit and I was able to identify the problem. It was a call to a database via Entity Framework that was badly written - i.e. the filtering was done after all the rows from the column in question had been fetched. And to make it worse, the filtering was done inside a foreach loop. Anyway, now everything is back to normal and I'm happy.
Possibly stating the obvious but you haven't got any silly code in your global asax in the app_start that could be causing this?
Sounds like an infinite loop or something?
Just a quick note what happend in my case:
Neither Process Monitor nor Failed Request Tracing was of any help. The website simply loaded (nearly) forever.
Finally, after waiting for several minutes an error occurred stating that it "cannot locate the network path".
The reason was that I entered a connection string to a non-existing SQL Server instance, so it somehow keept searching for the server. Finally, a timeout occured.
The solution was to simply specify the correct SQL Server in the connection string inside Web.Config.

Any Progress on Diagnosing “Request timed out” HttpExceptions?

I am having the same issue as described in this post, Diagnosing "Request timed out" HttpExceptions. I've turned on Failed Request Tracing as recommended and am working with someone at MS (although it's painfully slow).
The original post hasn't been updated in over a year, so I'm wondering if a fix was ever found or if you're just ignoring these errors.
Any help would be appreciated.
After over seven months of troubleshooting this issue, the fine folks at Microsoft finally tracked down the problem. It didn't end up being that complicated an issue, we all certainly learned a lot about IIS 7+ integrated mode.
In summary:
In IIS6 & IIS7+ Classic mode, the request doesn’t reach asp.net until the entire entity body is read. If the entity body doesn’t get completely read, asp.net has never been reached so http just logs the error and asp.net is never the wiser.
However, in IIS7+ Integrated mode, asp.net picks up the request immediately, so if the entity body doesn’t get completely read, asp.net logs the timeout and triggers the exception.
So, these exceptions can safely be ignored because they are expected behavior.
I really hope this helps someone else out there.

ServerError due to Memory issues?

In my Project (ASP.NET, VB.NET), sometimes a Server Error is showing.
When this error is shown, Users cannot submit their Applications, so that they have to re-type full details and submit again.
How can I escape from these Server Errors?
I think the reason may be Memory issues. Because if the user try to submit again (after Sign Out->Sign In ) then they can submit. Daily twice or thrice Error is happening.
The word "Server" in the phrase "Server Error" refers to your ASP.NET code. You are the server!
If you are running .NET 2.0 or later, you can look into the Application event log (use the Event Viewer applet) for warnings from "ASP.NET". They will include details of what went wrong.
You need to debug your code to find out what's causing this, but the event logs will give you a starting point.
"Server Error" is just a generic message that indicates the the server code (your code) threw an exception that wasn't handled. It shows the user "server error" instead of a specific message so that no implementation details are exposed to outside users.
In other words, without debugging or looking at a log file or something, all you can tell from "Server Error" is that an Exception of any type was thrown.
Sorry, but the information you provided is not helpful in determining the issue.
I think that you'll need to provide a bit more info to get meaningful solutions.
Do you have server logs?
Can you debug through the app as the error occurs?
Does the error occur at a certain time of day, or after a certain regular action?
Does your app attempt to write to a file that may not be accessible?
is it possible that you are experiencing memory issues?
the list could go on, best to do some more investigation and if a more specific issue comes to light edit your question with the extra detail.
AFTER EDIT:
From the extra detail you've provided I wouldn't jump to memory as an issue, in signing out and back in the user is refreshing their session so everything is reset. If you are not seeing anything in your logs you'll need to look at your exception/error handling.
You just haven't provided enough info yet for us to work out the root issue, let alone suggest a solution. That's what you're seeing from all the answers here thus far. Find the event log info and there should be something there to help you, or at least something more to post here.
Try debugging the error? Server Error can be caused by various reasons.
Check for potential infinite loops.
Check for code in the constructor that might fail (especially for web services).
I think I've had cases like this which led to 'Server Error'. I'm assuming you mean the big red 'Server Error' message?
Save all your files and close your Visual Studio and now right click on Visual studio and run as administrator. It worked for me.

Resources