StevieB
StevieB

Reputation: 6541

.NET Script Scheduler

Hey I have a .NET .aspx page that I would like to run every hour or so whats the best way to do this ?

I assume it will have to open a browser window to do so and if possible that it closes the window after.

EDIT : I have access over all features on the server

Upvotes: 1

Views: 848

Answers (3)

Heinzi
Heinzi

Reputation: 172468

Option 1: The cleanest solution would be to write a Windows application that does the work (instead of an aspx page) and schedule this application on the server using the Windows Task Scheduler. This has a few advantages over the aspx approach:

  • You can use the features of the Windows Task Scheduler (event log entries if the task could not be started, see the time of the last run, run the task in the context of a specific user, etc.).
  • You don't need to "simulate" a web browser call.
  • Your page cannot be "accidentally" called by a web user or a search engine.
  • It's conceptually cleaner: The main purpose of a web page is to provide information to the client, not to trigger an action on the server.

Of course, there are drawbacks as well:

  • You have two Visual Studio projects instead of one.
  • You might need to factor common code into a shared class library. (This can also be seen as an advantage.)
  • Your system becomes more complex and, thus, potentially harder to maintain.

Option 2: If you need to stick to an aspx page, the easiest solution is probably to call the page via a command-line web client in a scheduled task. Since Windows does not provide any built-in command-line web clients, you'd have to download one such as wget or curl. This related SO question contains the necessary command-line syntax:

Upvotes: 2

adt
adt

Reputation: 4360

You can use http://quartznet.sourceforge.net/ Quartz Job Scheduler.

With Quartz.net you can write a job which will request your web page with interval you choose.

or alternatively you can write an windows service which will request that web page.

Upvotes: 0

Farzin Zaker
Farzin Zaker

Reputation: 3606

use this sample to schedule a task in asp.net :

enter link description here

then you need to create Hit.aspx page witch will do what you want. then you should call that page every time (using WebClient class) the task execution time elapsed!

Upvotes: 0

Related Questions