CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

MS SQL 2008 on ASP.NET Hosting



Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.faq_frequently_asked_questions Tags:
Item Type: NewsGroup Date Entered: 11/21/2005 4:33:31 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 0 Views: 44 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
1 Items, 1 Pages 1 |< << Go >> >|
Aidy
Asp.Net User
Scheduling code and/or web requests11/21/2005 4:33:31 PM

0/0

ASP and ASP.net are request/response technologies which means the server only runs code in response to a client request. This makes scheduled jobs etc not really possible with asp.net. A scheduled job is code that runs at a certain time, not code that runs due a client request.


If you want something to happen at a certain time (send an e-mail, get some database reports etc) there are various ways around it depending what technology you have at your disposal.


If you have control over the web server itself then the best way to accomplish this is by writing your own Windows service. That's a little outside the scope of this post however. Next easiest is to use the Windows Scheduler to execute an app you have compiled. If your aim is to run a certain web page then that can also be handled via the scheduler.


Below is some code that will send an e-mail and request a web page. We'll then schedule this code to run at a certain time.


Create a new c# Console application and add a reference to System.Web. Now add these to the using list;


using System.Net;

using System.Web.Mail;


Update the Main function like so;


static void Main(string[] args)
{

    MailMessage m = new MailMessage();

    m.From = "[email protected]";
    m.To = "[email protected]";
    m.Subject = "Automated mail";
    m.Body = "This is an automated e-mail message.";

    SmtpMail.SmtpServer = "smtp.yoursmtpserver.com";
    SmtpMail.Send (m);

    WebRequest myRequest = WebRequest.Create("http://localhost/MyWebSite/MyScheduledPage.aspx");

    // If you want to request the page as a certain user, or if your target
    // url does not have enonymous access you can set the credentials as below.
    //myRequest.PreAuthenticate = true;
    //myRequest.Credentials = new NetworkCredential("username", "password", "domain");

    WebResponse myResponse = myRequest.GetResponse();
    myResponse.Close();

}


You'll need to amend the e-mail code to provide your own e-mail addresses and SMTP server. Compile and run the code to make sure it is working. If you want to process the response from the web page in some way then you can add code to do that; the above sample just requests the page which will cause the code on it to run but does nothing with the results.


Now open the Control Panel and select Scheduled Tasks->Add scheduled task. This will open the Scheduled Task Wizard. Click the Next button to continue then click Browse and browse for your compiled exe. You will be given a choice as to when to run it, so select Daily then click Next. Now you can select a time the task will be run at. Enter your desired time then click Next. Now you will be asked for the username and password of the NT user the task will be run as. Enter then and click Next. That is the task set up and you can click Finish, or optionally check the box that will open the task's properties for you. You should check the box so you can look at the kind of control you can exert over your scheduled task.


Now when your task runs it will execute your code.


If you don't have access to the server and can't set up scheduled tasks etc then your options are limited to an asp.net only solution. You can try the approach followed in this article;


http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=442


But be aware that if your site is inactive for a long time asp.net will end up shutting your components down.

1 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Network Algorithmics: An Interdisciplinary Approach to Designing Fast Networked Devices Authors: George Varghese, Pages: 496, Published: 2005
Quality of Future Internet Services: Second COST 263 International Workshop, QofIS 2001, Coimbra, Portugal, September 24-26, 2001 : Proceedings Authors: Mikhail I. Smirnov, COST 263(prosjekt), 2001 QofIS <2, Coimbra, Pages: 331, Published: 2001
Frontiers of WWW Research and Development--APWeb 2006: 8th Asia-Pacific Web Conference, Harbin, China, January 16-18, 2006 : Proceedings Authors: Xiaofang Zhou, Jianzhong Li, Heng Tao Shen, Masaru Kitsuregawa, Yanchun Zhang, Pages: 1223, Published: 2006
Programming Languages and Systems: 12th European Symposium on Programming, ESOP 2003, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2003, Warsaw, Poland, April 7-11, 2003 : Proceedings Authors: Pierpaolo Degano, Pages: 413, Published: 2003
IIS 6: The Complete Reference Authors: Hethe Henrickson, Scott R. Hofmann, Pages: 720, Published: 2003
Professional SQL Server 2005 Reporting Services Authors: Paul Turley, Todd Bryant, James Counihan, Dave DuVarney, Pages: 688, Published: 2006
Python Web Programming Authors: Steve Holden, David M. Beazley, Pages: 691, Published: 2002
Database: Enterprise, Skills and Innovation : 22nd British National Conference on Databases, BNCOD 22, Sunderland, UK, July 5-7, 2005 : Proceedings Authors: Mike Jackson, David Nelson, Sue Stirk, Pages: 184, Published: 2005

Web:
ARRLWeb: W1AW, the Hiram Percy Maxim Memorial Station Feb 5, 2008 ... World Wide Web: You can also find W1AW code practice here on ARRLWeb, ... At the beginning of each code practice session, the schedule for the ... To unsubscribe : Send an e-mail message to [email protected]. ...
Scheduling ASP.NET Code to Run Using Web and Windows Services Scheduling the running of ASP.NET code; N-tier architecture design; Web ... to HTTP requests, so a process or user input must call the code for it to run. ...
Web Records Policy & Guidance HHS Web Records Schedule – GRS References. Approved February 13, 2008. ... Templates, style sheets, and code that determine site architecture. ... Requests for information and copies of replies thereto, involving no administrative ...
Coldtags suite: Scheduler for web applications Scheduler for web applications. What if your web application requires some ... For the above mentioned approach (return the code for Ajax request to the ...
Open Source Job Scheduler Solutions - Web Services for Executable ... No style sheets are given for this Web Service as the Job Scheduler does not transform the request but immediately hands the order to the job chain. ...
City of Boulder, Colorado -- Official Web Site - Inspection Scheduling Oct 2, 2008 ... Enter four-digit inspection code. Request to have inspection results faxed ... Use Inspection Code 5000 to schedule all Rough Inspections. ...
WWW: WWW Alt. '04, Scheduling web requests in ... Unfortunately, most of existing on-demand scheduling algorithms did not consider the time constraints associated with web requests. ...
SitePoint » Web bugs for job scheduling: hack or solution? Nov 3, 2005 ... SitePoint.com - » Web bugs for job scheduling: hack or solution? ... With the cache turned on, Drupal stores all the HTML code for any page ... When another request for the same page comes along, Drupal knows to fetch ...
Schedule for web applications One useful trick lets you create a scheduler (cron daemon) in your web ... For the above mentioned approach (return the code for Ajax request to the real ...
Scheduling optimization for resource-intensive Web requests on ... Scheduling optimization for resource-intensive Web requests on server clusters. Zhu, Huican and Smith, ... ID Code: 63697. Deposited By: INVALID USER ...

Videos:
Developing JavaScript with Chickenfoot Google TechTalks July 25, 2006 Rob Miller Michael Bolin ABSTRACT Chickenfoot is a Firefox extension that embeds a JavaScript programming ...
A New Way to look at Networking Google Tech Talks August 30, 2006 Van Jacobson is a Research Fellow at PARC. Prior to that he was Chief Scientist and co-founder of Packet ...
How To Break Web Software - A look at security ... Google TechTalks April 13, 2006 Mike Andrews Mike Andrews is a senior consultant who specializes in software security and leads the web ...
Charlie Rose - Columnist Walter Mossberg; Reed Hastings ... Charlie Rose - Columnist Walter Mossberg; Reed Hastings, founder, Netflix.
Long Beach City Council Meeting Long Beach City Council Meeting
Long Beach City Council Meeting Long Beach City Council Meeting
Long Beach City Council Meeting Long Beach City Council Meeting
Long Beach City Council Meeting Long Beach City Council Meeting
Santa Monica Council Meeting Santa Monica Council Meeting
Long Beach City Council Meeting Long Beach City Council Meeting




Search This Site:










how do i export an excel file to a sql database in visual studio vb?

vs 2005 - i cant use the arrow keys to position controls, i could in vs2003.

web browser question

re:embed flash with asp.net

unwanted 403 errors when testing in vs2005 - cause and cure!

create web site... missing from recent projects panel of start page

web site name in solution explorer in .net 2.0

regasm : warning ra0000 : no types were registered

unabled to read the project....

horribly slow built time

what have i done to vs 05 toolbox?

swedish characters with fileupload component.

launching multiple pages with the built in web server

"failed to start monitoring changes" error....

error type 'system.timers.timer' cannot be serialized over wcf

selecting controls with a click and drag rectangle in visual developer studio 2005

file->new->web site is not providing the correct dialog for creating a new web site

&hc0000005& error in visual studio 2005 pro

lost /missing disc 3 of visual studio 2005 standard edition

"clean solution" --- what;s happening here?

that assembly does not allow partially trusted callers

customize precompilation (add post-build event)

property window is blank

show c# methods and variables in a window in visual studio

removing toolbox tab permanaently

package load failure

web.config exclude from vss?

wishlist

wec custom control

getting user control' forms all controls ids

  Privacy | Contact Us
All Times Are GMT