0

I have a script that generates a few large files (Product Feeds) and uploads them to different FTP locations.

This script needs to run daily.

whats the preferred route? its currently an aspx page but it doesn't need a user interface and doesn't need to run in the browser.

what are the best practices?

Is there a way to run a formless script in asp.net? I'd hate to install anything on the server even if it's my own console app.

The script also uses a dll (BVSoftware.BVC5) which might only work in a web application.

Currently its a scheduled task that opens IE on the server and loads the page and "Stop task if it runs longer than 1 hour" closes IE after an hour.

monsey11
  • 243
  • 4
  • 18

4 Answers4

1

I would simply create a console app that does the job and use the Windows Scheduler to schedule the nightly job.

Icarus
  • 63,293
  • 14
  • 100
  • 115
  • thanks, there is no way of running a formless script in asp.net? – monsey11 Aug 14 '12 at 16:24
  • I don't understand what you mean by "formless script". You can definitely take the code, create a new project and share it between the web app and the new console app - that's what I would do becasue that's DRY. Or... you could also look into selenium to automate the process (http://seleniumhq.org/) – Icarus Aug 14 '12 at 17:22
1

You could use a Scheduled Task, a Service, or, if you are going to be using a SQL script, a SQL Agent job.

See here: Writing a Scheduled Windows Service in .NET

Community
  • 1
  • 1
scott.korin
  • 2,537
  • 2
  • 23
  • 36
  • I was using a scheduled task to run the aspx page. but the meant that it would open a browser on the server and then it would need to be closed after a certain amount of time. – monsey11 Aug 14 '12 at 15:59
  • I should have specified I meant that if you use a scheduled task, you should write a console app. – scott.korin Aug 14 '12 at 16:03
  • console app means building an exe on my local machine and reinstalling on the server for every change. I thought there might be an easier path, have a script (instead of a webform) and schedule the script. – monsey11 Aug 14 '12 at 16:23
0

Since it is already working as an ASPX page, the least work is to simply use the Cache expiration to schedule a call to run it. However take care not to rely on it, because it may stop if the website is rarely used. See it here : How to schedule a C# code execution

Community
  • 1
  • 1
Allie
  • 1,081
  • 1
  • 13
  • 17
0

If you are trying to perform background tasks on a webserver, you could try using Worker Roles.

Or also BackgroundWorker thread: http://code.msdn.microsoft.com/CSASPNETBackgroundWorker-dda8d7b6

bPratik
  • 6,894
  • 4
  • 36
  • 67