MVC Website intermittent behavior of not reaching sometimes - asp.net

I have a ASP.Net MVC Website Hosted on IIS on couple of servers with load balancers, it a very simple page when it opens it logs user details in DB and show the view.
Issue is: It becomes unreachable sometime and pages are never opened. I have to restart APP Pool to get back on track and then it happens again.
What I have tried:
Made sure all DB connection are properly handled, any connection that gets opened are surely closed
Have put Recycle of APP Pool based on volume of RAM
Went through IIS logs and checked that request have reached there or not
There are other application also running on Server but the problem is isolated to this website
There are global users, issue persist of different global area
What I think it can be:
Might be possible that Load Balancer is never diverting my request
My request getting lost in between networks and layer
This is Production environment and we are not facing this issue in ACC or Dev.
What else I can go ahead and check?

Related

Why is my Application Pool stopping on first request after modifying Advanced Settings from a remote IIS client?

This started happening recently. After changing a couple of settings in the Advanced Settings window through a remote IIS client, the application pool automatically stops and I can't restart it without stopping again instantly or after its first web request.
What's interesting is that after getting that issue, I reenter the Identity credentials being used in the same Advanced Settings window, and the Application Pool works again.
There are no messages in the Event viewer.
The only plausible explanation is that saving the settings through a remote client somehow messes up with the Identity used. If I change the same settings directly on the server, I don't get this issue.
Has anyone had this happen before?

Azure Webapp - Receiving 502 page error

I have a web site deployed under App Services of Azure. It is working well up to couple of days before. But since two days Iam receiving below error
502 - Web server received an invalid response while acting as a gateway or proxy server.
There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.
When I access Site with xyz.azurewebsites.net it doesn't show this error. This is only displayed when I access with custom domain name. I have enabled Failure Request Tracing, but FREB logs doesn't show any 502 errors.
Can anyone help me understand what's the issue is?
Thanks
Azure WebApps have ARR sever (aka the FrontEnd) in front of the actual machines serving the web applications (known as the workers) and HTTP 502 is returned via the FrontEnd servers typically under these conditions
The request is taking a really long time on the actual worker
machine to execute
The worker process corresponding to the web
application is not even running or crashing multiple times.
Since the HTTP 502 error is happening on the FrontEnd servers, you won’t see these in the IIS logs because the IIS logs are of the worker so basically in your case either the request is taking too long to execute or the worker process serving the request (on the actual worker machine) is crashing.
As you mentioned that things work when you access the site over a custom domain vs xyz.azurewebsites.net then I would suggest checking a few things.
Make sure that your custom domain is really resolving to the right xyz.azurewebsites.net. Try using www.digwebinterface.com and put your custom domain there and make sure that it resolves to xyz.azurewebsites.net
Check if by any chance your code does something special for requests which arrive on your custom domain. Meaning any special processing like database lookups, or URLRewrite rules getting triggered etc. for requests only to custom domains.
Also check in your FREB logs to see if you can spot any long running requests when the hostname contains custom domain. You can use the FREB Viewer under the Support Portal for your WebApp to check this easily
Check if the WebApp is crashing by going to the EventViewer under the Support Portal for your WebApp and see if there are any crash related events.
You can reach the support portal of your WebApp by going to https://xyz.scm.azurewebsites.net/Support (where xyz is name of your Azure WebApp)
If this doesn’t help, then I recommend engaging Microsoft Support as they can check some of these things easily at their end.

IIS & hosted ASP.Net application

Let's suppose I have an ASP.Net web application hosted by IIS. In addition to the functionality serving requests I added an action executed periodically on specified interval, e.g. every 30 minutes. This action is not related to external web requests, for example, its purpose is deleting useless log files.
The question is: if nobody comes to my web site for long period of time (day, week) will IIS still keep my application alive and the above action will be executed every 30 min. Or IIS will shut down/suspend activity of the application if there are no requests for long time?
Perhaps it is a lame question but I failed to find the definite answer.
IIS doesn't shut down, but IIS will recycle your app after a certain period of time of unuse.
So if your app is responsible for firing off the event, then no it won't run if your app is not running (recycled).
Either have a service hit your website once in awhile or setup a scheduled task on the server if you have access to the machine.
If you're on shared hosting you'll have to check their features to see if they have something like that.
Also, if you're just trying to delete log files or something trivial and not time sensitive (since you won't have logs unless someone is hitting your site), you could just perform your action in Application_Start. This even will fire whenever IIS restarts your application.

Asp.Net page does not respond until cookies are deleted

We have deployed our Asp.Net webforms app on Azure platform, the app is being served by two web servers load balanced. Asp.Net session is managed by memcashed.
Generally app works fine but randomly it gets hanged, if we try to reload the app, request is not getting processed by the browser, no error at all, continuous loading.
Only way to make the app work again is by DELETING COOKIES for this specific app from the browser.
This happens in Firefox as well as in Chrome so does not seem to be a browser specific issue.
Cookies in particular is not that heavy, there are only 3 cookies, 1 being asp.net session cookie and two other for persisting user credentials.
App is about real-time chat service so it polls web server at each 4 seconds.
We have already referred one similar issue but that does not help.
If it happens randomly it looks like it caused by load balanced configuration. From my experience the most common reason for issues with load balanced farm - different machineKey values.
Try to check you have the same machineKey value in web.config for both servers.

Mechanics of ASP.NET Cache Expiration?

I have a task that I want to be run 8am daily and am considering this solution: https://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/
But I'm not understanding the mechanics of how it works.
Say user X visits the site on Friday at 4pm and then closes his browser and turns his computer off. Will the cache expiration still fire on Saturday at 8am? If no users visit the site, will my process still fire every day?
Basically, my question boils down to, is this method reliable? Or is it dependent on users visiting the site?
ASP.NET Application When hosted (started) on IIS fires few Events, of Which Application_Start is one of the foremost. Setting a Background task then keeps running untill the Application is stopped/unloaded from IIS, or IIS service itself is stopped. IIS is a host process for all ASP.NET Websites.
Since the Cache is maintained on the Web Server, it has nothing to do with the active user(s).
This is analogous to a console aplpication, where the first line of code is adding something to a cache with a timer. runs as long as your console application is up and running.
Hope this helps you!
The server side cache is different to the browser cache. Users closing their browsers won't effect Jeff's code at all. However, if your application pool shuts down (and it may if there aren't any users hitting the site) then your code won't run at all until someone browses to the site, the app pool spins up again, and then it's 8am the next day (assuming the app pool is still up).

Resources