Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Scheduler in ASP.NET with C#

Posted on 2004-04-15
5
Medium Priority
?
3,037 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 320 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
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 …
Introduction to Processes

580 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