I have a ASP.NET webpage call page1. In Page_Load(), I created a watcher that watches change of score.txt
file:
var watcher = new FileSystemWatcher(@"D:\");
watcher.EnableRaisingEvents = true;
watcher.IncludeSubdirectories = true;
watcher.Filter = "score.txt";
I want the page to refresh when score.txt
file changes, so I add an event like this:
watcher.Changed += (o, a) =>
{
Response.Redirect(Request.RawUrl);
};
Unfortunately, when I changed the score.txt file manually and save it, the VS2017 throws an exception right at Response.Redirect(Request.RawUrl)
: System.Web.HttpException: 'Response is not available in this context.'
I try googling but there is still no solution. Could anyone point out what's wrong with my program? Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire