Solved

Scheduler in ASP.NET with C#

Posted on 2004-04-15
5
3,021 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now