Solved

Scheduler in ASP.NET with C#

Posted on 2004-04-15
5
3,028 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 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 DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

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

Suggested Solutions

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In this post we will learn different types of Android Layout and some basics of an Android App.
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 …

710 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