Source code: Click to download the source code
Run the code in application_start of Global. asax.
A problem occurs here, that is, you cannot use httpcontext. Current. server. mappath ("~ /Xxx.txt "); an error is returned: NULL reference!
Then google found the solution: system. Web. Hosting. hostingenvironment. mappath ("~ /Xxx.txt "); replace!
The original code was found online (the link cannot be found ......), It can only be written to one class. The modified class can be executed after being set by default. aspx.
At first, I used a model layer to store the set time. Later I found that it was not working because the program first loaded global. the code in asax (if you set a breakpoint, you can see it). At this time, the interface has not been loaded, so the data in the model is empty, and it is useless even if you have finished setting, because Global has been executed.
There is no way to think of a stupid method later, that is, to write the set to a TXT file through the default. aspx page, and read it from it when the program is running. That's all.
Source code: Click to download the source code