Solved

Scheduler in ASP.NET with C#

Posted on 2004-04-15
5
3,025 Views
Last Modified: 2008-07-23
Hi Experts,

I created an .aspx file which whenever I load/run it in the Micosoft Visual Studio.Net, it will be able to sending email to member, by retrieving their email address/data from database.
As I already done this part.

But now I need to change the program, so that it will take care by the Window's built in Scheduler Task to run the pogram and send out the email.

Now, when I set the scheduler task to run this file, it will only open the file.aspx in Studio.Net, but not running the sending email function.

And I'm lost in how to do it.

Please help me...

Regards,
dummy82

0
Comment
Question by:dummy82
  • 4
5 Comments
 

Accepted Solution

by:
esandler earned 80 total points
ID: 10832210
You cannot put an ASPX file to run, an ASP.NET host application must compile it and run it. This is done automatically for you if you access the page via a URL.

To perform what you want you can do the following 3 things:

1) Create a console application that access using the WebClient class in .NET the URL that is the ASPX page. This will make IIS run the page and perform the operation. You can than put this console app using the Windows Scheduler and it will run periodically.

2) Put the Email sending code into an assembly so you will be able to call it from the ASPX page and you will be able to write a small console app (.exe) that will call the same code.

3) Create a ASP.NET hosting application that will run your ASPX file.



I suggest option 1, because it is very simple. Option 2 is also fesible, option 3 is very tricky, so I would avoid it.
0
 

Author Comment

by:dummy82
ID: 10838549
Thanx esandler,

I decided to use option 1.

Now, I created a Console Application, Class1.cs.
May I know what you mean by access using the web client class...?
Can give me some sample code or procedure on how to continue?

Please advise.

Regards,
dummy82
0
 

Author Comment

by:dummy82
ID: 10840262
I tried :

class Class
{
  [STAThread]
  static void Main(string[] args)
  {      
     WebClient client = new WebClient();
     client.OpenRead"http://localhost/AsiaSeminar/Administrator/Scheduler/Scheduler.aspx");
     Console.Read();      
  }
}

It gives me a blank Command Prompt, and seems like not running the function in  "Scheduler.aspx".

Please help.
0
 

Author Comment

by:dummy82
ID: 10840519
Sorry esandler,

I already trouble shoot on my own.
And the Window built-in scheduler can run the console application and call my file, Scheduler.aspx.
Really have to thanx a lot for your suggestion.

Cheers.

Regards,
dummy82


0
 

Author Comment

by:dummy82
ID: 11065681
Hi expert,

I face this problem again....

May I know how to use the method 1 ? The browser cannot openthe yahoo page..
Please help...

Below is my code:

class Class
{
      [STAThread]
      static void Main(string[] args)
      {    
      WebClient client = new WebClient();
      client.OpenRead("http://www.yahoo.com");
      Console.Read();    
                }
}
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is about my first experience with programming Arduino.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question