Weird webpage loading behaviour - asp.net

I have a website that I'm hosting on a public IP using IIS 7.0. (using c# asp.net 3.5)
I find that if I navigate to the webpage for the first time in a day. It loads endlessly and nothing shows up. Then when I re-press enter in the address bar, it loads right away and everything works fine.
From then on, when I got to the address again it loads quickly.
I don't think this is a compilation issue as all my code is pre-compiled.
Any ideas what might be causing this behavior?
Thanks!
Andrew

I had a similar problem which turned out to be caused by the IIS app pool recycling.
In my case, the website had outgrown its hosting package and as soon as it hit the arbitrary memory limit, the app pool was recycled and the application restarted, recompiling on the first page view.
You can check for this by adding a Global.asax and handling the Application_Start event. You could write logs to a database or send an email notification with whatever debug details you want.
I also handle Application_Error which offered up some useful info.
If you notice Application_Start happening several times a day, you may have a memory leak or similar issue.

Related

How to track intermittent issue with loading/non loading of web site in ASP.NET MVC 5

I am beginner in web development. And I am working in an ASP.Net MVC 5 application and stuck with a very weird issue.
Issue:
Sometimes my web site just won't load in the browser. When I run in the local dev machine, website loads properly (localhost). But in LIVE the browser will keep on loading the website but nothing would load.
Also
After half an hour or so, website again kicks back in and starts opening properly.
Action I took:
Sometimes restarting the WebSite from IIS fixes the issue, BUT NOT ALL THE TIME. Sometimes even restarting did not fix the issue.
Also, I checked the Chrome Debugger, I do not see any error there (when the website was not loading).
I know something called ELMAH exists. Or some error logging in IIS. Can some one tell me how can I track this issue, in step by step process. Why my website will keep on trying to load in browser but will never load But after some time it loads. Is it IIS issue?
KINDLY NOTE: Once it starts loding fine, then even if I close the website and reopens it, It opens superfast like a flash. So the hiccups comes sometimes only.
I am willing to put more details, in this question. but I am not sure what to put. as far as IIS is concerned, all I know is how to restart and stop my website. that's it.
EDIT
Step 1: So, I searched event viewer as a whole in windows search and found something like below.
Edit 3
I checked the windows log, I do not see any issue related to my web app.
I know something called ELMAH exists.
Elmah is alogging framework. With just installing the NuGet package you already have an effective error logging mechanism in place. All unhandled exceptions will be logged with all the related information. It provides a page to visualize your logs and you can configure almost everything from security, to different back-end storages.
If you need a cloud base error logger with more advanced features you can use elmah.io.
Take a look at this post for a step by step guide on how to integrate elmah.

Losing Session information after publishing an ASP.NET Website on IIS

I'm a beginner in ASP.NET 2.0.Probably this could sound too basic and stupid issue for someone expert in the ASP.NET.But this is giving me sleepless nights.
Basically i have developed a simple multilingual website with a master page and content pages which fills inside the content place holder portions of the master page. The application works great when it is configured to run on the ASP.NET Development Server 2.0. But once i publish it to run on the IIS web server it will no longer function. :( I could see from the trace that none of the session variables i use are stored and redirected to the relevant content pages.
Although the contents are displayed, the session variable values by which i take some decisions on the redirected pages are lost and i run into exceptions.
Please guide me where am i going wrong and exact procedure for Publishing an application.
Ex: my home page has URL which runs something like
http://localhost/Onlineupdate/Home.aspx?vers=1.1&lang=fr-FR
Based on the above URL, i strip and save the vers and the lang variables in a Session variable. However these are lost when hosted on IIS.
There are a dozen or so things that could cause the session data to be lost:
IIS restarting
The app pool restarting
due to a change to the web.config
due to a change to anything in the \bin directory
memory limit reached, or a bug causing the app pool to reset.
several other possible causes
Your host is actually a web farm, and you're using in-process memory, which will cause issues when one server fails over to the other, unless you're using SQL Server session state mode.
Since we don't have enough information to answer exactly what's happening in your specific situation, I'd ask you to start by reading up, starting here: http://msdn.microsoft.com/en-us/library/ms178581.aspx
Edit: I did find this blog article, which may be helpful: http://blogs.msdn.com/b/amenon/archive/2007/08/21/troubleshooting-session-loss.aspx
The following is not necessarily part of the answer, but added to try to be helpful.
If it's feasible, from my own personal experience, we've had success in eliminating our lost session issues by using the SqlServer Session State mode. Since we implemented this, our session issues have all but disappeared.
also i found the main problem that you should initialize session before use
like:
session[“id”]=””;
and after that it well work fine
In order to prevent this to happen first in the web.config set restartOnExternalChanges to false.
Now in web.config changes must be propagated manually(this means that the dev is now responsible to build a mechanism for config change propagation).
Hint: You can use file watcher for this that will listen for the web.config (or any config you use in you web. app) for changes and wrap it as a watchable configuration so you can reload the configs when they are changed.
Hope this helps
I faced the same issue in my ASP.NET MVC website .
and i have resolve it by next steps :
open IIS Manager
go to the application pools
right click on the application pool which related to your website
click on "Advanced Settings"
set "Idle Time-out (minutes)" to be "20"
set "Maximum Worker Processes" to be "1"
Click Ok to close the window
these steps has resolved my issue.

Random Page not found error on asp.net application in IE6

Lately we are receiving complaints from users about Page not Found errors on production environment. This happens during Login page load or default page load in the asp.net application.
The application on the production environment did throw the Page not Found error. But when we tried to access the same application from test environment it worked without any problem.
I have read about client-side handling for form submission which results in a race condition with the form being submitted twice. IE 6 turns out to be especially vulnerable to this problem because of how it handles multiple connections to the same hostname.
I am unable to figure out what could be the issue because the application runs fine on other machines and only specific machines give this problem.
Try disabling the button after the first click, therefore blocking multiple clicks. Also have you tried replicating on production? Perhaps it is environment specific.
It was some machine configuration. The infrastructure team could not quite figure out what the issue was, but they formatted the machines which resolved the issues for the user. Not the best of solutions.
Logs did not indicate any detail.

What are possible causes for App_Offline.htm not bringing the site down?

Normally, I use App_Offline.htm for taking the site offline. But occasionally, when I do that, the site just hangs (like in: browsers wait forever, server gives no response at all). This seems to happen on an updateable site when I change something, like a control and afterward, when it doesn't go quick enough (site hangs), I place App_Offline.htm in the root of the website.
In most cases, this immediately takes down my site. But occasionally it doesn't. In those cases, I cannot just stop the website (when I restart, the behavior continues). Stopping the application pool doesn't let me restart the same app pool. The only two solution so far is restarting the whole IIS web service.
I'd like to prevent this from happening. Is this a bug in IIS not "breaking all actions" when App_Offline.htm is found? I use IIS 7 with Windows 2008 SP2 64 bit.
What I found was that my web.config file either had an error in it or was missing. When this is the case, app_offline.htm does not get processed.
IIS should not stop existing actions, only prevent new requests from going through: Will app_offline.htm stop current requests or just new requests?
It sounds like you are describing a scenario where you update a control, try to load a page, and IE is stuck loading. At this point you drop the app_offline.htm and expect to see that page immediately.
If you are making a completely separate/new request after putting app_offline.htm in place then you should see the page come up. However the existing request will not be affected as linked above.
If possible try deploying the app_offline.htm file prior to making the control change.
I am not sure what you mean by "Stopping the application pool doesn't let me restart the same app pool"...if you meant that you can't restart the pool immediately after stopping it, thats because it isn't stopped yet. Depending on the number of Worker Processes in that pool it may take a min for it to completely spin down so it can accept the start command.
Also, I would think you would have to restart the pool in order for the app_offline.htm to work effectively anyway.
Here's the thing.
Everytime when you open the .sln at the server, or updating the code, it will create the app_offline ticket in the root.
This is the feature from asp.net itself to prevent any access to disturb your development.
Delete the app_offline manually everytime after you open the .sln.
hope this help.
thanks.
Another possibility is a missing handler. The following handler is required:
ExtensionlessUrlHandler-Integrated-4.0
To fix the issue you need to at a minimum:
Wait the length of your website timeout to ensure all requests have finished.
Background processes kicked off from a web request will mean further extending the length of time you wait beyond the website timeout
Unload any unmanaged code by hooking into the DomainUnload or Application_End events
I'm waiting 3 minutes for App_Offline.htm to take affect and this seems has allowed App_Offline.htm to work as expected.

Classic ASP on IIS 7

I am having problems with my app running on IIS 7. The application is a mixture of classic ASP and ASP.NET MVC (don't ask how and why).
Anyway, the application is up and running except for some problems that I am experiencing. For example, I have a button on my page and when I click it, javascript is opening a popup which needs to contain .asp page. But that doesn't happen. I get the blank popup with my cursor on busy as it still loads. This is happening almost always to me in IE. In Firefox it is much better but sometimes the app jams there too.
If I close the opened, blank popup, and I want to move around the application, my buttons in menu (which are also .asp) doesn't load properly. For example, I have different buttons for different sections and when I move around they should change. When I restart the browser, only then everything works normal for some time, but the problem occurs again after a while.
I am very sure that it is not the problem in application itself, because it works properly on the machines of my colleagues without those problems. They have the same OS (Vista Professional) and we compared the settings in IIS and they match.
So I am very confused, and I really don't know how to solve the problem. I found a bunch of articles and blog posts about classic ASP and IIS7 but most of them are about enabling asp, which I already did.
So I am suspecting that something wrong with IIS, but I don't know what, tried to reinstall it, hoping for some improvement, but I had no luck.
If you need more details please ask.
Does anyone have any idea what should I try or do?
When debugging ASP.NET or ASP apart from the VS itself the most important tool you need is Fiddler (free tool from MS). This allows you to observe the http sessions the occur between your server and the client. This tool will give much greater visibility on what is actually happening underneath.
Next Step
So you now know that the problem is server side and the URL of the resource causing the problem. The next step is to debug the server side process by attaching to the w3wp.exe that is serving your site. If the resource specified by the URL is an ASP paged attach for script debugging or if its ASP.NET attach for Managed Code debugging. (Note for ASP debugging you will need to enable ASP server side debugging in the ASP settings in IIS manager).
You should place a break point on the first entry point of code for the resource. Now you can step through the code and discover where it is locking up.

Resources