Help: Server.Execute throws exception in Application_Start

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
 
B

Brock Allen

If you want a backgrould thread, then create a System.Threading.Thread object.
Server.Execute is a sychronous mechanism to execute a second page from the
execution of a first page.
 
G

Guest

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.
 
B

Brock Allen

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?
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top