Help: Server.Execute throws exception in Application_Start

  • Thread starter Thread starter frog
  • Start date Start date
F

frog

Hi, all:

I tried to call Server.Execute in Application_Start
and got exception.
Any help is appreciated

You might ask why I want to do that in the first place.
Well, I need to
start a background thread in the Application_Start. This
background thread
need send Emails. The content of email is from executing
a webpage. In
short, this background need to call the Server.Execute
which throws exception.

frog
 
Thanks for answering the question.

I need to send email in the background thread, and the
email content need to be generated from ASPX pages.

Well of course, I can use web-services to create this
email content...

But I am looking for a simpler solution.. Any help is
appreciated.


-----Original Message-----
If you want a backgrould thread, then create a
System.Threading.Thread object.
 
I need to send email in the background thread, and the email content
need to be generated from ASPX pages.

Can you explain a bit more? If the email needs to be send in the context
of a page, then why not just write the code in the page itself? Why Application_Start?

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
Why dont you spawn a new thread on application on start that either creates a
a webrequest that invokes your .aspx page that appears to be sending out
emails. For a very crued example something like this would work:

private void Application_OnStart(object sender,EventArgs e)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(RunUrl));
}

public void RunUrl(Object stateInfo)
{
Process.Start("explorer","http://www.google.com");
}

of course there are many ways to accomplish this task this is just a quick
and dirty methodology example.
 
Back
Top