Home > Net >  To write a web server to clean up once a day
To write a web server to clean up once a day

Time:09-15

Online search method is written in the book of Global asax Application_Start, iis after start-up, there are the first person to visit the web site, will be executed, there are some small wonder: 1, someone visit, will be executed, then the user closes the page, there will be affected? More than 2, personal visit, will be executed multiple times? 3, if, after an execution, so long as you don't close the iis timing task will not end?

CodePudding user response:

Application_Start this thing, may be changed because the IIS application pool what reason or other unexpected restart,

Do you time to perform a task, or need to perform the logging preserved, avoid repeat or miss,

CodePudding user response:

Is to want to perform MSMQ message queue, but don't want to use a Windows service, want to write in the project, that according to you mean, is if you can record the operation records and can be used is this?

CodePudding user response:

Or a Windows service, Application_Start this thing almost no longer on the actual application, you can't control when it will restart,

CodePudding user response:

reference ying1234 reply: 3/f
or a Windows service, Application_Start this thing almost no longer on the actual application, you can't control when it will restart,
alas, sad

CodePudding user response:

It doesn't matter.. We will use the most simple way to debate..

To instantiate a timer when you appstart hypothesis 1 hour once. Once a day, so whatever you write a H=number (0-23).

Good now some people say that there will be a restart or accidental restart or automatic recovery. But they are not stop...

Is just perform the action will still appstart.. There will be a new timer

CodePudding user response:

Need not ocd, need not be entangled with what a day, iis

Your system won't because the hang up, you make sure 2 or 3 days can be executed n times the ability is good (1 & lt; N<20).

If your system will be postponed because you 1 minute to clean up hang up, data is not allowed, can only say that your system needs to be redesigned
Such as financial night nuclear, this business need to perform 1 times a day, so when this kind of request, you still entangled with what iis Application_Start? It's clear that he needs to be designed

CodePudding user response:

Cleanliness and obsessive-compulsive disorder and can't help you solve the problem,

I only said that if he does not produce what effect, so I can assure you he will perform, and does not guarantee that he carried out a what time,

3 days no access iis, don't start the application pool, affect the business?
Then three days later the man does not affect the business visit do have a problem?

Visit and do affect the business? No effect or negligible, you worry what
If there is influence and must do, will involve the design again, that is, the above said "business needs to reconstruct, rather than the cleanliness and obsessive-compulsive disorder let you endless worry"

CodePudding user response:

After the global.asax Application_Start will begin in iis, there are the first person to visit the web site, will be executed, can be inside a Timer System. Timers. The Timer, but after no one to visit the web site, will be closed down default 20 minutes after application (depends on the web. Config set the Timeout time & lt; SessionState mode="InProc cookieless"="false" timeout="20" & gt; ) Timer is not running, the program was off, and then someone visit the web site, will rerun the Application_Start method

CodePudding user response:

refer to 7th floor wanghui0380 response:
cleanliness and obsessive-compulsive disorder and can't help you solve the problem,

I only said that if he does not produce what effect, so I can assure you he will perform, and does not guarantee that he carried out a what time,

3 days no access iis, don't start the application pool, affect the business?
Then three days later the man does not affect the business visit do have a problem?

Visit and do affect the business? No effect or negligible, you worry what
If there is influence and must do, will involve the design again, namely the above said "business needs to reconstruct, rather than the cleanliness and obsessive-compulsive disorder let you endless worry about"
ok, says is very clear, thank you

CodePudding user response:

refer to the eighth floor yesterday have response:
Global. Asax Application_Start will begin in iis, there are the first person to visit the web site, will be executed, can be inside a Timer System. Timers. The Timer, but after no one to visit the web site, will be closed down default 20 minutes after application (depends on the web. Config set the Timeout time & lt; SessionState mode="InProc cookieless"="false" timeout="20" & gt; ) Timer is not running, the program was off, and then someone visit the web site, will rerun the Application_Start method
understand, thank you

CodePudding user response:

Application_End here you write a visit himself not have

 protected void Application_End (object sender, EventArgs e) 
{
System. Threading. Thread. Sleep (5000);
The string url="http://localhost:XXXX//XXXXX";
System.Net.HttpWebRequest the req=(System.Net.HttpWebRequest) System.Net.WebRequest.Create (url);
System.Net.HttpWebResponse RSP=(System.Net.HttpWebResponse) the req. The method GetResponse ();
A string of TMP=RSP. StatusDescription;
String errorlogtime=DateTime. Now. ToString (" yyyyMMddhhmmssfff "). The ToString ();
If (sched!=null)
{
Sched. Shutdown (true);
}
}

CodePudding user response:

Or you baidu Quartz.net writing tasks in the framework

CodePudding user response:

Good

CodePudding user response:

In fact, really don't have to tangle,

We take a look at some famous design

Redis: redis said, overdue don't expire have so important, some people visit I will perform the expired inspection, no one visit I expired expired not important, well, you said that you don't want to check, OK, modify the configuration, become outdated push notification, I'm talking about having a timer to play (like redis said is, of course, this timer is not very accurate, I do not guarantee the accuracy, ensure that he will be removed)

This style also got netcore famerwork runtimecache is to provide real-time remove notification, but into the netcore cache, but won't give you real-time removed, he said like redis, is "anyway, he always remove, you visit before I go to check, do not access other I don't need to make an inspection, waste of performance"
  •  Tags:  
  • C#
  • Related