Help: Server.Execute throws exception in Application_Start

Discussion in 'ASP .Net' started by frog, May 6, 2005.

  1. frog

    frog Guest

    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
     
    frog, May 6, 2005
    #1
    1. Advertising

  2. frog

    Brock Allen Guest

    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.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen


    > 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
    >
     
    Brock Allen, May 6, 2005
    #2
    1. Advertising

  3. frog

    Guest 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.
    >Server.Execute is a sychronous mechanism to execute a

    second page from the
    >execution of a first page.
    >
    >-Brock
    >DevelopMentor
    >http://staff.develop.com/ballen
    >
    >
    >> 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
    >>

    >
    >
    >
    >.
    >
     
    Guest, May 6, 2005
    #3
  4. frog

    Brock Allen Guest

    > 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
     
    Brock Allen, May 6, 2005
    #4
  5. 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.

    "Brock Allen" wrote:

    > > 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
    >
    >
    >
    >
     
    =?Utf-8?B?V2lsbA==?=, May 18, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Miller
    Replies:
    4
    Views:
    13,568
    Chris Smith
    Nov 22, 2003
  2. John Dalberg
    Replies:
    4
    Views:
    3,424
    Alexey Smirnov
    May 10, 2007
  3. Replies:
    2
    Views:
    357
  4. Replies:
    7
    Views:
    375
  5. frog
    Replies:
    0
    Views:
    131
Loading...

Share This Page