Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Scheduler in ASP.NET with C#

Posted on 2004-04-15
5
Medium Priority
?
3,030 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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 …

722 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