So I've been trying to figure out why the application pool keeps crashing every now and then, and I've pinpointed the page that is cau seems to be causing the issue.
When I open the site in the browser, and visit the Shipping cart page (after adding stuff to the cart), the entire browser becomes unresponsive, and I open Task Manager, and see that IE (browser) is using 99% CPU, so I right-click > Create DUMP > Try to read DUMP but WinDBG does not seem to like DMP files; won't read them.
So I move on, and try to figure it out without the dump files. I fire up Visual Studio, open the site in question, and then follow the same process (add stuff to cart, then visit cart page). And to my surprise, everything is OK.
Not sure what to do now. Any suggestions? How would you determine the cause of the hanging, when everything runs perfectly, locally - and when everything used to run perfectly online, but no longer runs fine online?
If the browser becomes unresponsive and eats 99% CPU, that's a client side problem; it most likely doesn't have anything to do with IIS or your server side code.
Could it be that you have some javascript in your page is buggy and goes into a busy loop? I think it's worth a shot to test this (use either IE's developer tools (F12), Visual Studio's javascript debugging functionality, or FireFox in combination with FireBug).
Edit
It strikes me as odd that your AppPool crashes, and in doing so, causes the web browser to turn non-responsive. With non-responsive, do you really mean that the browser itself stops working (i.e. navigating a page back or going to another url such as google.com is impossible?)
Anyway, if you think the problems occur on the server-side, you could try the following things (in order of increasing effort):
After an AppPool crash, check the windows event log (run 'eventvwr' from a command prompt) and see what information that gives you.
View the IIS log (you might have to turn it on first), see if it contains any weird request patterns, such as your page getting hammered)
Run your website from IIS, but attach a debugger from Visual Studio (under Tools, Attach to process - include only managed code) to the IIS worker process (usually w3wp.exe). If your page throws an exception, VS should be able to catch it.
Add more tracing to your page, the Global.asax's Application_Error seems like a particularly good candidate.
Related
Is there one kind soul out there who has the time to help me figure out why my application is intermittently hanging (and hopefully how to fix it)? I'm running a web program from VS2015 that accesses a SQL Server database. Sometimes I'll click on a link on my webpage and everything works fine. Other times, though, the little circle just spins forever, and it never comes back. It doesn't seem to be related to the database because one time I caught it hanging on a call to XmlSerializer serializer = new XmlSerializer(type);
I'm running the website in IIS Express on localhost on a Windows 10 laptop (16GB & plenty of disk). I also have ReSharper if anyone thinks that can help me diagnose the problem. I've been fighting with this for days and have no idea what else to do but hope that someone here will have pity on me.
Re: D Stanley's comments: "Do you have any logging? Can you run it in the debugger to see where it's hanging? Is there anything in the system event logs?"
There is logging, but only on caught exceptions. Nothing that will help the hang situation. I can run it in the debugger, but when it's hung I can't see where it's hung (it's in External Code). The Event Log does report a "perflib" error when I run the program. I can post that info if you think it would help.
More info. I installed Fiddler. When the application is hung, Fiddler is still going to town. The "Process" it's showing is "scriptedsandbox64", which is doing I/O and consuming CPU time.
I suggest you add lots more log messages to your code, something like:
DateTime.Now.ToString("o") "Starting xxx"
DateTime.Now.ToString("o") "Finished xxx"
where xxx is a name for some chunk of code. You suspect the problem is in external code, so wrap all those calls.
You can then see where the application spends excessive time. Once you have found the right area, then perhaps add more logging to focus in on the problem.
The answer to my hanging problem was to use Local IIS instead of IIS Express. Once I figured out how to set up the website for localhost and began running with Local IIS my hangs disappeared.
I have a strange issue that occurs every day. I have recently been given a fellow developers laptop with Windows7 & IIS6 (they've left) and my previous laptop (WidnowsXP & IIS 5) has been recycled into the system, so I'm stuck with this one and didn't originally set up the system. Developing worked fine on my old computer, but on this one.
I am developing an ASP.NET website and after a while of editing, building, then going to localhost in IE, the page doesn't show. The process w3wp.exe isn't in my list of processes in the task manager. If I call iisreset.exe, this usually fixes it at first (i.e. going to localhost starts w3wp.exe and after a short while my page appears).
After a few runs of this, even this fix doesn't work, but I've found that if I close IE, then run iisreset.exe it fixes it.
Then after a few runs of this, I also have to close Visual Studio & IE, then iisreset.exe. Once I get to this stage, I can't make a single edit in visual studio without having to close it to run the web page. Note, I'm not running in debug mode. I've even tried editing in notepad++ for simple edits and I have to close that too before iisreset works!
Eventually I end up restarting my computer because these incantations stop working. I'm at the end of my tether. Does anyone know what could actually be wrong or where I should start looking for a real fix?
I have a Silverlight project that we use internally that I wrote - and since we've not had any need to work on it, it's been a while since I've opened the project. I opened it up this morning and everything is fine in terms of building, but whenever I try to debug I get the following error:
Unable to start program "http://mymachinename/mywebsite/index.aspx"
Of course, running it in Firefox works fine but no symbols are loaded. Running without debugging still throws the same error but IE loads up anyway...
Navigating to the website in IE works fine - SL app opens up, loads data etc etc, all looks good
I've Googled this all morning (usually quite good at finding info) and been through all the questions on SO and I can't figure out what's going on - there doesn't seem to be any messages in the event log, there are no messages in any VS output window, the w3wp just terminates immediately after starting (probably due to there being an error trying to open IE). I've tried reinstalling IE, cleaning/rebuilding, using local dev server, creating a new web project, turning on/off settings in IE9 etc etc
Nothing seems to make a difference - anyone got any experiences of this and has fixed it without doing one of the things I've already done? Any other suggestions?
Thanks in advance!
UPDATE
Just to be clear in case anyone asks - I get this problem when creating a new web project - i.e. everything I said I'd tried (above) didn't change the behaviour. It showed the same error no matter what I'd done so far (that includes a NON SL web project)
I've also tried attaching the debugger to w3wp that is running (the standard IIS process) and I can't seem to get it to debug (no symbols are loading), but that might be another issue altogether. I'm going to look at that next and maybe if I figure that out it might lead to fixing this issue
UPDATE 2
Debugging in Firefox works - I attached to w3wp with no success, then realising my stupidity (SL being a client side app!) I attached to the plugin-container.exe that FF runs its plugins in. This works. I can probably do the same for IE and just attach to IE, but why won't it start up from VS?! hair pull
UPDATE 3
Just in case anyone asks, the default browser is set to IE in VS. Also I've managed to debug by attaching to IE, it just won't start IE from within VS - annoying but I can live with it for now. If anyone does have a suggestion though, feel free...
For anyone's information in case they have this same problem, it ended up being that the port I was running my site on was also running a SharePoint site!
I created a new site on port 81 and used that for dev - not sure what setting on the other site caused the issue but it ended up working on port 81.
I have recently rolled out a new ASP .Net application. This application uses .Net 4.0 and the Entity Framework 4. It is a "basic" CRUD application. I almost exclusively used the EntityDataSource for Data Access.
The users have reported "ocassional freezing" of the application (they all use IE 8). If the user closes his browser and starts back up, the app is fine. It happens maybe once or twice per day total, usually to the heavy users. (So, I have been leaning toward memory leack or some other kind of resource limitation.)
Until just a little while ago, I have never seen this happen. It dosn't leave anything in the Event Log on the client PC nor Server. Also, there is nothing in the IIS error logs or the SQL logs.
A little while ago, I finally got it to happen. I was switching all of my EntityDataSources to use a single Object Context per page. I downloaded the EF Profiler (which seems to be a great product) and it pointed out that I am using multiple object contexts on many of my pages, due to the fact that many of them have more than one EntityDataSource. So, I was cleaning all this up and testing each page, when lo and behold....IE stopped loading pages!
At first, the page started loading slowly (and this was a page that I had already modified to use a single Object Context, so although I still believe I need to implement this "singleton" pattern throughout all my pages, I guess it isn't the culprit! Anyway..), then at some point I received:
Message: Sys.WebForms.PageRequestManagerTimeoutException: The server request timed out.
Still, nothing in the Event Log. I also checked the IIS web logs and I don't see anything, but they are pretty tough to read with the naked eye, I may have to download a parser to make sure there is nothing in there.
Anyway, I decided to start up another window and navigate to my app, and sure enough that window worked fine, no problems. I went back to the windows that stopped responding, refreshed it, waited... went to the home page of my app (which is basically just some static html.. and nothing.. ). Next, I opened a new tab in the window that is currently frozen and that tab works fine. So, I go back to the window that can no longer load pages from my app and try some other web sites.... espn.com loads fine, msn.com loads fine, I then enter the URL for my app home page (and tried some other pages in my app) and NOTHING. IIS doesn't even log the attempts in its Log Files (its like IE has just decided not to do anymore "gets" for my localhost!). Finally, after waiting for a while (while I was typing this post) I now have this error message in that window:
Internet Explorer cannot display the webpage. What you can try: The problem can be caused by a variety of issues, including: BLAH BLAH BLAH...
So, I jump back to that window and it can still browse Internet sites just fine. But, once again when I try to go to any of the pages in my app, I get NOTHING (spinning blue circle in the tab). So, once again I start a new tab in that same browser and I can browse around my application just fine.
What has my app done to this browser instance that will no longer let it load any of its pages (in fact, it seems like it isn't even doing a GET on any of the apps pages, since there is nothing new in the IIS logs...except for when I load the pages in these other tabs and/or browser windows that work fine, so the logging is still working...)? I will be forever indebted to the person that can help me figure this out. I am not sure it will do much good, but I am going to leave this browser window up on the chance that someone can tell me some things to try to diagnose this problem. It feel like I am THIS close to figuring it out. I finally have a window up that is misbehaving. I am afraid to close the window or do a new build on the app until I get some good input on things to try....
I should add that when this happened to me, I was running on my local PC, so I was the only user and only had one window open to the app..
Although, I am completely stumped!
We had the same issue and seemed to fix it by adding the following JavaScript to all pages with ajax:
window.onunload = abortRequest;
function abortRequest() {
Sys.WebForms.PageRequestManager.getInstance().abortPostBack();
}
I hope this helps!
sounds like a request just takes too long to execute. A web-browser is only allowed to keep two concurrent connections to a single webserver unless you utilize http pipelining (which isn't well supported anyway). However, My experience is that this is per browser, not per tab.
This is why nothing shows up in your logs, because your browser never initiate a request because it is waiting for the page to finish loading before it can fetch another page. I would start looking into the last request initiated before the lockup, it is probably that page that locks for some reason and never finishes.
ASP.NET utilizes only one thread as long as all request are sequential. As soon as you fire up two request simultaneously, a new thread is initiated (Init() on HttpApplication is invoked), and that can cause intermittent errors if you do funky stuff on Init().
If you think this is related to EF, you might read up on how to avoid locking in multi-threaded environment (because a web application is very much multi-threaded however this usually kicks in a production environment).
Ugh, I feel your pain - I hate these types of issues. Here's my divide-n-conquer process when something like this is happening (adapted somewhat to your case):
Step 1 - Environment Visibility
Get yourself set up so you can roughly see inside your systems. Set up Performance Monitor, and add a couple of important counters (IIS Current Requests, ASP.NET Current Requests, SQL Server - Active Transactions). The idea here with the "active requests/transactions" counters is you want to find out which part of the system is holding on to the request.
Additionally, add counters for total request time in IIS and the DB (so you can see it climbing as something is hanging on).
On your client PC, set up Fiddler.
Step 2 - Reproduce Issue
Usually at this point, the application realizes you can see it and starts behaving perfectly. ;) Stop and make sure you can still reproduce the issue.
Step 3 - Take the DB out of the equation
Create 4 pages in your application:
Static HTML file (.htm) that will NOT go through the ASP.NET runtime engine. This is your baseline for raw IIS.
ASPX page with no tricks (no database access, no processing, just a simple page that ASP.NET can spit out)
ASPX page with one simple database call (of some size, maybe do a single big query or something)
ASPX page with some complex transactions (multiple queries, etc)
Step 4 - Reproduce and measure
Since this issue will probably be pretty obvious once you can see it, find the bottleneck with your performance counters and Fiddler. Your issue sounds like you could have an intermittent connectivity issue (either between client and web server or web server/SQL), especially if IE is giving you the "page cannot be displayed" error, but you should see that in Fiddler. On the server side, you should see one of those performance counters hanging.
well, sounds like the app is waiting for a database operation to complete but is locked, probably because of another operation.
Try using the SQL profiler to trace the activity, and isolate what processes are running for a long time.
You can differentiate the requests using the SPID column in the trace view, it contains a unique ID number for each session from your App.
I have new information regarding this issue.
The application uses Integrated Authentication. This causes every reqest to come back (twice) with access denied, before IE send the credentials.
I can't help but wonder if this is what could be causing the "time outs".
I implemented an Ajax "Loading" animation on every page that prevents the user from clicking a button until the previous request is completed and that has GREATLY diminished the amount of "freezes" the users are experiencing.
Although, it still happens somewhat often.
In an ASP.NET Web Site project, I've always been able to make changes to the underlying C# code and simply refresh the page in the browser and my changes would be there instantly.
I can do the same thing when working with Java and Eclipse - edit my Java source and refresh the page and my changes are there.
I cannot do this in ASP.NET MVC though and it is a real downer - I have to stop the running process and make my changes, and then restart debugging. This is a huge waste of time.
Am I doing it wrong? What is the best approach to ASP.NET MVC development?
I rarely use debug mode in ASP.NET MVC project (F5). I run the project once with CTRL+F5 and always have a browser window open. Then if I make a change to a view (.aspx, .ascx), I hit F5 in the browser and changes automatically take effect. If I have to do changes in the .NET code (controller logic, models, repositories, etc...) I no longer use the browser. To verify that my change is correct I navigate to the corresponding unit test and hit CTRL+R+T. The result is seen either in green or red.
Visual Studio locks the source code in debug mode. So your options are:
Publish the site on your local IIS and use the "attach to proccess".
Use Run without Debug (Ctrl-F5) instead and again "attach to proccess".
Break the execution in debug mode (with Breakpoint).
The first one is my favorite.
You don't have to stop the process, you can break.
Try breaking the project, then editing, then continue.
1) CTRL-ALT-BREAK
2) Edit your code
3) F5
My technique has been to launch it normally then copy the URL from the browser and open another window for the website then kill the original. Once you kill the original browser, VS lets your source code go but you still have it up in another window and can navigate it normally. Now you can edit your code and then refresh the browser and it works just like before.
The only reason to launch it normally first because VS seems to pick a random port number against localhost when firing up the built in IIS. But even that rarely changes
My URL usually looks something like this:
http://localhost:49434/something.apsx
The port numbe changes on occasion but it seems to stay the same as long as you dont close visual studio. Once you kill VS your URL will fail.
Run the MVC project with shortcut key (CTRL + F5) and now any changes you make to the C# code would be reflected in browser after refreshing (F5)
The fastest way to code is to Host locally on IIS and then all you have to do is build the solution before checking out your changes.
Another alternative is chucking everything into the App_Code folder which will compile on the fly as you make changes.