Alternative to resetting the asp "Windows Services" every few days - asp.net

One of my site is on a shared hosting and every few days the site will stop working.
The pages will simply stop loading.
After contacting my host they suggested that I disable/re-enable from their hosting
management tool the windows services for my site every time this happens.
In the list on their website I have: ASP, ASP.net and 2 other that I don't need.
When I disable and than immediately re-enable the 2 asp services the site does start
working again right away.
I'm under the impression that this is a probably due to a wrong configuration of the
application pool my domain is using but they're refusing to give details. No
automatic recycle maybe?
Beside changing host, do you have any suggestion about this problem?
Do you believe it's an app pool setup issue like I do or do you have any other
idea on what else could be causing this issue and/or ideas for a permanent solution?
Thanks.

I think there is something wrong with your code. I once ran into a similar issue with my web host and found out later that the app was leaking memory due to some resources that were opened and never closed. I suggest you inspect the code a bit more.

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.

Web application in IIS not picking up the correct root

I don't know if I'm doing something very obvious incorrectly, but for some reason my web app thinks that it's root folder is different to what it actually is.
I have created a web application below Default Web Site. Whenever I have done this in the past, and understanding of how it's supposed to work, is that any requests to the application root (for URL routing, for example ~/index.aspx or for images) have always resolved to [server][applicationname]\index.aspx.
For some reason, whenever I do this with this particular application, instead of going to [server][applicationname]\index.aspx, I'm being redirected to [server]\index.aspx, and for the life of me, and after extensive googling and fiddling with settings, I can't get it to pick up the correct path.
Any suggestions?
When you go to your site in II7, first make sure your site is highlighted. Then click Basic Settings on the right hand side. Double check the Physical Path in the popup window.
Well, I don't know what the problem was, but after restarting the website it seemed to go away and is now working as expected. It's possible that it was caused by the application previously being a web site, and then I converted it to a web app without restarting it, although I did recycle the app pool.
Cheers for the comments - I'll leave this as the answer in case someone has a similar problem in future.

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.

ASP.Net / Umbraco Website has (initially) very high server response time

I've got this problem.
I launched an ASP.NET website with the Umbraco CMS on an ISP.
(Its just a very basic informative site. nothing special.)
When I go want to visit the website however, the first pageload takes a lot of time, sometimes even up to 20 seconds. Of course this is ridiculous.
Afterwards, I am able to navigate the site relatively quick..
So every first pageload is slow, then everything is OK, more or less.
Does anybody have any idea what the problem could be? Would it be IIS? ASP.NET?
IIS is probably configured to shutdown the application pool after N minutes of inactivity.
AFAIK, this is the default behaviour on IIS.
If it is the first request to be served, IIS at least starts the APP Pool. This might take a bit of a time. Maybe Umbraco loads initially some data, but I did not have any experience with Umbraco, so that's beyond my knowledge.
-sa
What do you meen by first page load?
Have you just done a build? If this is a website then .Net will compile and load the dll. Then IIS will cache page outputs.
Do you have any large images on the page?
Essentially there are an infinate number of reasons. Have you used firebug? Determine where the loadtime is?
Do you have a link?
You may want to look into a keep alive service. There are many available that regularly poll you site to keep the application pool running and prevent the startup delay you are seeing. More information here and here.

How to put an asp.net application into offlince/maintenance mode?

I've developed my first web application which, surprisingly, is getting very popular.
Because the website is now live, I have a hard time doing some changes, in fear some people are still logged in and are using the application.
I wish to avoid having a duplicated instance of the web application for testing.
Is there any way to put the website in 'maintenance mode' with only me having access to it? Like redirecting to a page with some info, telling its in maintenance mode.
I wish to avoid having a duplicated
instance of the web application for
testing.
That's your problem right there. For anything but the most trivial sites, you should have a staging or development instance. You should be using source control and have a script to update the main instance.
You can simply drop a file called app_offline.htm in the root of your website and ASP.NET will automatically route all traffic to this page. This file can contain any HTML you wish indicating that your site is down for a short period due to maintenance.
For more information please read App_Offline.htm and working around the "IE Friendly Errors" feature:
The way app_offline.htm works is that
you place this file in the root of the
application. When ASP.NET sees it, it
will shut-down the app-domain for the
application (and not restart it for
requests) and instead send back the
contents of the app_offline.htm file
in response to all new dynamic
requests for the application. When
you are done updating the site, just
delete the file and it will come back
online.
This is the answer to your question:
http://www.codeproject.com/Tips/219637/Put-the-website-in-Maintanance-Mode-Under-Construc
There's no such built-in functionality in ASP.NET except app_offline.htm which doesn't quite fit your needs because even you will be denied access to the site. You have to build it on your own but this is best done on the routers and load balancers level than at the application level. Of course this will depend on your network architecture.
Besides building a dev replica of your website to build patches and fixes on, couldn't you just announce a site closing for maintenance several days in advance? I'm not a web programmer, but you might want look into what Hattrick, a popular online soccer management, does for maintaining their site. They use a notification system on the homepage, after users sign-in, that announces when maintenance will be taking place (usually late at night in Europe where a large portion of the players and all the devs are located) and they close down the website for a couple of hours. When they take the site down they post a page, using the same style as the rest of the site, and provide an estimate of when it will be up and running again. Simple, elegant, and when coupled with the long forewarning it seems to do a good job placating the user base.
Give users a long heads up that planned maintenance is scheduled to take place and give them some idea what it is for and most people will be able to accommodate the down time. Nothing is more frustrating than purposefully going to a web app that was up and running 10-20 minutes ago to find it suddenly unavailable and down for maintenance.
Try app_offline.htm ??
What version of ASP.NET? I'm sure there are a million more elegant ways of doing this, but you can change the Default Document in IIS to redirect to Maint.html (or similar).

Resources