Reputation: 859
I need to to be able to detect a .csv file which will be dropped on an FTP Server. When the file is transferred it should trigger code to read the file and then upload all the information from the .csv file to a SQL Server. After the file is transferred it should then run a few other functions which will essentially validate what is uploaded and perform some calculations.
In the ideal sense the functions should execute once the file is dropped(run in the background without any human interaction). I've found where FileWatcher was used in C# applications but not in MVC.
Does anyone have any examples where this is accomplished in Asp.net MVC 5 or a better solution to this?
Thanks.
Upvotes: 1
Views: 932
Reputation: 6718
There is a C# sample for the FileSystemWatcher here. But a web application running in IIS is not the best platform for a long-running thread. IIS will kill your threads periodically as it performs application pool recycling and then try to recreate them sometimes with unexpected results. After some time not receiving any web request, IIS goes to sleep and your thread will also stop working. When changing IIS configuration to force it not to do these things, memory leaks and other mean things may occur. Years ago, we've worked with Quartz.Net and faced all sorts of issues (suddenly not running, raising memory exceptions, etc) till we moved the scheduler thread from an ASP.Net web application to a Windows Service and worked fine. I don't think IIS is thought for doing what you want to do.
Upvotes: 1