asp.net mvc 4 - Doing a webrequest to self, periodically, to prevent IIS from killing the app -


why isn't working? iis kills app anyway after 20 mins

    protected void application_start()     {         task.factory.startnew(() => daemonstuff());     }      private void daemonstuff()     {         // ping self         mywebrequest selfrequest = new mywebrequest(myurl, "get");         selfrequest.getresponse();          // sleep         thread.sleep(1000 * 60 * 5);      } 

what i'm doing here visiting own site (with webrequest) every 5 minutes.

this way, iis shouldnt think site idle, because getting visits, kills app anyway.

so: possible fake visits own site every 5 minutes doesn't killed?

the problem asp.net doesn’t know work done on background thread spawned using timer or task. knows work associated request. asp.net don't know work you’re doing , not prevent iis/asp.net turn off web site.

a more robust solution use iregisteredobject explanained here.

at last, sure myurl correct ? check iis logs this.

at last², maybe best solution disable idle timeout in iis : change 'idle timeout' in pool's advanced settings.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -