How to start code when IIS starts - Any expert?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • AW

    How to start code when IIS starts - Any expert?

    Hello,

    I have a method to initialize my application, which reads configuration
    settings, establishes connections, and loads a bunch of data. It lasts for
    several seconds.

    This method is called in the Application_Sta rt event, but this means that
    the first person requesting for a page will undergo a severe wait.

    Can someone recommend a way to do so that I can call this method BEFORE any
    page is called? Do I have to plug into IIS and know when the server is
    started?

    Thanks,
    AW
    --
    To reply, remove a "l" before the @ sign.

    AW - MCT, MCSD.Net, MCAD.Net


  • Mark Fitzpatrick

    #2
    Re: How to start code when IIS starts - Any expert?

    Your best bet is to do it the way you are doing it. The application will
    only start when someone hits the page. It will also unload 20 minutes after
    the last session is killed. This is an excellent way to do it in order to
    get the memory management features and ensure application stability and
    performance. Your best bet instead may be to have a windows task sitting
    somewhere that just hits a particular page every 19 minutes. That way
    ensuring that there's always a session in the application domain so it won't
    unload and if a user hasn't hit the site yet the app will be forced to load.

    Hope this helps,
    Mark Fitzpatrick
    Microsoft MVP - Frontpage

    "AW" <aweill@fr.xrt. com> wrote in message
    news:ulCuJRtnDH A.2080@TK2MSFTN GP10.phx.gbl...[color=blue]
    > Hello,
    >
    > I have a method to initialize my application, which reads configuration
    > settings, establishes connections, and loads a bunch of data. It lasts for
    > several seconds.
    >
    > This method is called in the Application_Sta rt event, but this means that
    > the first person requesting for a page will undergo a severe wait.
    >
    > Can someone recommend a way to do so that I can call this method BEFORE[/color]
    any[color=blue]
    > page is called? Do I have to plug into IIS and know when the server is
    > started?
    >
    > Thanks,
    > AW
    > --
    > To reply, remove a "l" before the @ sign.
    >
    > AW - MCT, MCSD.Net, MCAD.Net
    >
    >[/color]


    Comment

    • AW

      #3
      Re: How to start code when IIS starts - Any expert?

      Thanks Mark for your answer.

      I understand that it would be best to theoretically wait for the first user
      to start the application, but practically this can't be tolerated because of
      the several seconds needed for initialization.

      The workaround that you mention seems like a good idea, but isn't it
      possible to do something that's more tightly tied with IIS? I mean, instead
      of making an HTTP request, can't I call directly an IIS API or, better an
      ASP.Net API?

      Thanks for your help.
      --
      To reply, remove a "l" before the @ sign.

      AW - MCT, MCSD.Net, MCAD.Net


      Comment

      • msnews.microsoft.com

        #4
        Re: How to start code when IIS starts - Any expert?

        AW,

        Here are some suggestions that may help your situation:

        1.) Compile your .dll with the method you call in application_ons tart into a
        native image using ngen.

        2.) Cache the data you retrieve and use either timespan or file dependencies
        to refresh the cache appropriately.

        That should give you some of the performance boost you're seeking.

        Regards,

        Bryce Budd
        "AW" <aweill@fr.xrt. com> wrote in message
        news:ulCuJRtnDH A.2080@TK2MSFTN GP10.phx.gbl...[color=blue]
        > Hello,
        >
        > I have a method to initialize my application, which reads configuration
        > settings, establishes connections, and loads a bunch of data. It lasts for
        > several seconds.
        >
        > This method is called in the Application_Sta rt event, but this means that
        > the first person requesting for a page will undergo a severe wait.
        >
        > Can someone recommend a way to do so that I can call this method BEFORE[/color]
        any[color=blue]
        > page is called? Do I have to plug into IIS and know when the server is
        > started?
        >
        > Thanks,
        > AW
        > --
        > To reply, remove a "l" before the @ sign.
        >
        > AW - MCT, MCSD.Net, MCAD.Net
        >
        >[/color]


        Comment

        • AW

          #5
          Re: How to start code when IIS starts - Any expert?

          Thanks Bryce.

          These are good ways to speed up the initialization part, but still a good
          part of the work can't be optimized (database connections establishment, for
          instance). So I really need a way to do this part of the work *before*
          anybody uses the application, instead of just speeding it up.
          --
          To reply, remove a "l" before the @ sign.

          AW - MCT, MCSD.Net, MCAD.Net


          Comment

          Working...