简体   繁体   中英

How to schedule downloading of files on server using ASP.NET web page

How to download a file from a web server to another iis server

eg I have lot of movie files which i want to host on my website

the movies are uploaded on other site and I want to grab them on my own site.

Is it possible to schedule asynchronously downloading of files on server using ASP.NET web page? I have only FTP access to the web sever as I'm using shared hosting.

One things you can do is make use of Window Services ie create Window service and put timer in that will resolve you issue easily.

here is good article: Combine Web and Windows Services to Run Your ASP.NET Code at Scheduled Intervals

If you are using shared hosting, scheduling tasks is going to be difficult. You could implement a service page that performs the download when it is requested. This page would run on the destination server and request a list of files from the source server and proceed to download those files. The server performs all the work, the client that requests the service page could just get a short log of what the server is doing.

Next setup a scheduled task on some other system that invokes the service page at regular intervals.

Since the call to the service page is a very low load on the client you could do that from just about anywhere (a home or office server, a smart router (dd-wrt) you have sitting in closet somewhere or even your smart phone).

Nice bonus of this approach is that you can manually trigger downloading from anywhere by accessing the service page from your browser directly.

On the downside, if the time to complete the downloads exceed the maximum request duration your request is likely to be terminated. You may want to look into asynchronous handlers if that happens.

You could wire a task to run on every page load or application start (and recycle the app pool regularly), but ASP.NET isn't designed for this type of task.

You would be better served building a service or command line tool that can be attached to Task Scheduler to do the downloads every so often.

1) Add entries to a queue in your ASP.Net application - either MSMQ or database table.

2) Write a windows service/console application that reads from the queue and processes each item.

You could also achieve (2) with ScheduledTask in SQL - ton of other ways too no doubt - the key thing is that you put the queue in the middle to provide the disconnection and asychrony.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM