When is IHttpModule.Dispose method called?

Discussion in 'ASP .Net' started by =?Utf-8?B?U2ltb25lIEJ1c29saQ==?=, Jan 3, 2006.

  1. Hello, I am trying to understand when IHttpModule.Dispose method is called.
    Is it called when the Application is disposed, or when the request ends?

    If I want to make an object Application-wide and close it when the
    application ends can I use that method or write something like this in the
    class that implements the IHttpModule?

    public void Init(HttpApplication application)
    {
    application.Disposed +=new EventHandler(application_Disposed);
    }

    private void application_Disposed(object sender, EventArgs e)
    {
    // close my object here
    }

    Thanks in advance.

    --
    Simone Busoli
     
    =?Utf-8?B?U2ltb25lIEJ1c29saQ==?=, Jan 3, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?U2ltb25lIEJ1c29saQ==?=

    Karl Seguin Guest

    I hope this doesn't sound rude, but the documentation, for 2.0 atleast,
    makes this pretty clear:
    "The Dispose method performs any final cleanup work prior to removal of the
    module from the execution pipeline."

    which would mean it's application-wide.

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/
    http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!



    "Simone Busoli" <> wrote in message
    news:...
    > Hello, I am trying to understand when IHttpModule.Dispose method is
    > called.
    > Is it called when the Application is disposed, or when the request ends?
    >
    > If I want to make an object Application-wide and close it when the
    > application ends can I use that method or write something like this in the
    > class that implements the IHttpModule?
    >
    > public void Init(HttpApplication application)
    > {
    > application.Disposed +=new EventHandler(application_Disposed);
    > }
    >
    > private void application_Disposed(object sender, EventArgs e)
    > {
    > // close my object here
    > }
    >
    > Thanks in advance.
    >
    > --
    > Simone Busoli
     
    Karl Seguin, Jan 3, 2006
    #2
    1. Advertising

  3. It's what the documentation says for 1.1 too, but it didn't sound to me very
    clear. I'd be glad if you could explain the reason why it is so clear.

    --
    Simone Busoli


    "Karl Seguin" wrote:

    > I hope this doesn't sound rude, but the documentation, for 2.0 atleast,
    > makes this pretty clear:
    > "The Dispose method performs any final cleanup work prior to removal of the
    > module from the execution pipeline."
    >
    > which would mean it's application-wide.
    >
    > Karl
    >
    > --
    > MY ASP.Net tutorials
    > http://www.openmymind.net/
    > http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
    >
    >
    >
    > "Simone Busoli" <> wrote in message
    > news:...
    > > Hello, I am trying to understand when IHttpModule.Dispose method is
    > > called.
    > > Is it called when the Application is disposed, or when the request ends?
    > >
    > > If I want to make an object Application-wide and close it when the
    > > application ends can I use that method or write something like this in the
    > > class that implements the IHttpModule?
    > >
    > > public void Init(HttpApplication application)
    > > {
    > > application.Disposed +=new EventHandler(application_Disposed);
    > > }
    > >
    > > private void application_Disposed(object sender, EventArgs e)
    > > {
    > > // close my object here
    > > }
    > >
    > > Thanks in advance.
    > >
    > > --
    > > Simone Busoli

    >
    >
    >
     
    =?Utf-8?B?U2ltb25lIEJ1c29saQ==?=, Jan 3, 2006
    #3
  4. =?Utf-8?B?U2ltb25lIEJ1c29saQ==?=

    Karl Seguin Guest

    I guess it isn't if you don't know what the ASP.NET pipeline is...which a
    lot of people wouldn't.

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/
    http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!



    "Simone Busoli" <> wrote in message
    news:...
    > It's what the documentation says for 1.1 too, but it didn't sound to me
    > very
    > clear. I'd be glad if you could explain the reason why it is so clear.
    >
    > --
    > Simone Busoli
    >
    >
    > "Karl Seguin" wrote:
    >
    >> I hope this doesn't sound rude, but the documentation, for 2.0 atleast,
    >> makes this pretty clear:
    >> "The Dispose method performs any final cleanup work prior to removal of
    >> the
    >> module from the execution pipeline."
    >>
    >> which would mean it's application-wide.
    >>
    >> Karl
    >>
    >> --
    >> MY ASP.Net tutorials
    >> http://www.openmymind.net/
    >> http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
    >>
    >>
    >>
    >> "Simone Busoli" <> wrote in message
    >> news:...
    >> > Hello, I am trying to understand when IHttpModule.Dispose method is
    >> > called.
    >> > Is it called when the Application is disposed, or when the request
    >> > ends?
    >> >
    >> > If I want to make an object Application-wide and close it when the
    >> > application ends can I use that method or write something like this in
    >> > the
    >> > class that implements the IHttpModule?
    >> >
    >> > public void Init(HttpApplication application)
    >> > {
    >> > application.Disposed +=new EventHandler(application_Disposed);
    >> > }
    >> >
    >> > private void application_Disposed(object sender, EventArgs e)
    >> > {
    >> > // close my object here
    >> > }
    >> >
    >> > Thanks in advance.
    >> >
    >> > --
    >> > Simone Busoli

    >>
    >>
    >>
     
    Karl Seguin, Jan 3, 2006
    #4
  5. I am sorry if I made stupid questions, but I think this is not the way to
    reply to a question. But thank you anyway.

    --
    Simone Busoli


    "Karl Seguin" wrote:

    > I guess it isn't if you don't know what the ASP.NET pipeline is...which a
    > lot of people wouldn't.
    >
    > Karl
    >
    > --
    > MY ASP.Net tutorials
    > http://www.openmymind.net/
    > http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
    >
    >
    >
    > "Simone Busoli" <> wrote in message
    > news:...
    > > It's what the documentation says for 1.1 too, but it didn't sound to me
    > > very
    > > clear. I'd be glad if you could explain the reason why it is so clear.
    > >
    > > --
    > > Simone Busoli
    > >
    > >
    > > "Karl Seguin" wrote:
    > >
    > >> I hope this doesn't sound rude, but the documentation, for 2.0 atleast,
    > >> makes this pretty clear:
    > >> "The Dispose method performs any final cleanup work prior to removal of
    > >> the
    > >> module from the execution pipeline."
    > >>
    > >> which would mean it's application-wide.
    > >>
    > >> Karl
    > >>
    > >> --
    > >> MY ASP.Net tutorials
    > >> http://www.openmymind.net/
    > >> http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
    > >>
    > >>
    > >>
    > >> "Simone Busoli" <> wrote in message
    > >> news:...
    > >> > Hello, I am trying to understand when IHttpModule.Dispose method is
    > >> > called.
    > >> > Is it called when the Application is disposed, or when the request
    > >> > ends?
    > >> >
    > >> > If I want to make an object Application-wide and close it when the
    > >> > application ends can I use that method or write something like this in
    > >> > the
    > >> > class that implements the IHttpModule?
    > >> >
    > >> > public void Init(HttpApplication application)
    > >> > {
    > >> > application.Disposed +=new EventHandler(application_Disposed);
    > >> > }
    > >> >
    > >> > private void application_Disposed(object sender, EventArgs e)
    > >> > {
    > >> > // close my object here
    > >> > }
    > >> >
    > >> > Thanks in advance.
    > >> >
    > >> > --
    > >> > Simone Busoli
    > >>
    > >>
    > >>

    >
    >
    >
     
    =?Utf-8?B?U2ltb25lIEJ1c29saQ==?=, Jan 3, 2006
    #5
  6. =?Utf-8?B?U2ltb25lIEJ1c29saQ==?=

    Karl Seguin Guest

    No, I'm the one who's sorry. The question wasn't stupid and I was rude. We
    typically aren't like this in here..

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/
    http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!



    "Simone Busoli" <> wrote in message
    news:...
    >I am sorry if I made stupid questions, but I think this is not the way to
    > reply to a question. But thank you anyway.
    >
    > --
    > Simone Busoli
    >
    >
    > "Karl Seguin" wrote:
    >
    >> I guess it isn't if you don't know what the ASP.NET pipeline is...which a
    >> lot of people wouldn't.
    >>
    >> Karl
    >>
    >> --
    >> MY ASP.Net tutorials
    >> http://www.openmymind.net/
    >> http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
    >>
    >>
    >>
    >> "Simone Busoli" <> wrote in message
    >> news:...
    >> > It's what the documentation says for 1.1 too, but it didn't sound to me
    >> > very
    >> > clear. I'd be glad if you could explain the reason why it is so clear.
    >> >
    >> > --
    >> > Simone Busoli
    >> >
    >> >
    >> > "Karl Seguin" wrote:
    >> >
    >> >> I hope this doesn't sound rude, but the documentation, for 2.0
    >> >> atleast,
    >> >> makes this pretty clear:
    >> >> "The Dispose method performs any final cleanup work prior to removal
    >> >> of
    >> >> the
    >> >> module from the execution pipeline."
    >> >>
    >> >> which would mean it's application-wide.
    >> >>
    >> >> Karl
    >> >>
    >> >> --
    >> >> MY ASP.Net tutorials
    >> >> http://www.openmymind.net/
    >> >> http://openmymind.net/redirector.aspx?documentId=51 - Learn about
    >> >> AJAX!
    >> >>
    >> >>
    >> >>
    >> >> "Simone Busoli" <> wrote in
    >> >> message
    >> >> news:...
    >> >> > Hello, I am trying to understand when IHttpModule.Dispose method is
    >> >> > called.
    >> >> > Is it called when the Application is disposed, or when the request
    >> >> > ends?
    >> >> >
    >> >> > If I want to make an object Application-wide and close it when the
    >> >> > application ends can I use that method or write something like this
    >> >> > in
    >> >> > the
    >> >> > class that implements the IHttpModule?
    >> >> >
    >> >> > public void Init(HttpApplication application)
    >> >> > {
    >> >> > application.Disposed +=new EventHandler(application_Disposed);
    >> >> > }
    >> >> >
    >> >> > private void application_Disposed(object sender, EventArgs e)
    >> >> > {
    >> >> > // close my object here
    >> >> > }
    >> >> >
    >> >> > Thanks in advance.
    >> >> >
    >> >> > --
    >> >> > Simone Busoli
    >> >>
    >> >>
    >> >>

    >>
    >>
    >>
     
    Karl Seguin, Jan 3, 2006
    #6
  7. It's ok. Anyway trying by myself I found out that using the IHttpModule
    Dispose method and an event handler for the Application.Disposed event should
    be barely the same. The first occurs right after the second one.

    --
    Simone Busoli


    "Karl Seguin" wrote:

    > No, I'm the one who's sorry. The question wasn't stupid and I was rude. We
    > typically aren't like this in here..
    >
    > Karl
    >
    > --
    > MY ASP.Net tutorials
    > http://www.openmymind.net/
    > http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
    >
    >
    >
    > "Simone Busoli" <> wrote in message
    > news:...
    > >I am sorry if I made stupid questions, but I think this is not the way to
    > > reply to a question. But thank you anyway.
    > >
    > > --
    > > Simone Busoli
    > >
    > >
    > > "Karl Seguin" wrote:
    > >
    > >> I guess it isn't if you don't know what the ASP.NET pipeline is...which a
    > >> lot of people wouldn't.
    > >>
    > >> Karl
    > >>
    > >> --
    > >> MY ASP.Net tutorials
    > >> http://www.openmymind.net/
    > >> http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
    > >>
    > >>
    > >>
    > >> "Simone Busoli" <> wrote in message
    > >> news:...
    > >> > It's what the documentation says for 1.1 too, but it didn't sound to me
    > >> > very
    > >> > clear. I'd be glad if you could explain the reason why it is so clear.
    > >> >
    > >> > --
    > >> > Simone Busoli
    > >> >
    > >> >
    > >> > "Karl Seguin" wrote:
    > >> >
    > >> >> I hope this doesn't sound rude, but the documentation, for 2.0
    > >> >> atleast,
    > >> >> makes this pretty clear:
    > >> >> "The Dispose method performs any final cleanup work prior to removal
    > >> >> of
    > >> >> the
    > >> >> module from the execution pipeline."
    > >> >>
    > >> >> which would mean it's application-wide.
    > >> >>
    > >> >> Karl
    > >> >>
    > >> >> --
    > >> >> MY ASP.Net tutorials
    > >> >> http://www.openmymind.net/
    > >> >> http://openmymind.net/redirector.aspx?documentId=51 - Learn about
    > >> >> AJAX!
    > >> >>
    > >> >>
    > >> >>
    > >> >> "Simone Busoli" <> wrote in
    > >> >> message
    > >> >> news:...
    > >> >> > Hello, I am trying to understand when IHttpModule.Dispose method is
    > >> >> > called.
    > >> >> > Is it called when the Application is disposed, or when the request
    > >> >> > ends?
    > >> >> >
    > >> >> > If I want to make an object Application-wide and close it when the
    > >> >> > application ends can I use that method or write something like this
    > >> >> > in
    > >> >> > the
    > >> >> > class that implements the IHttpModule?
    > >> >> >
    > >> >> > public void Init(HttpApplication application)
    > >> >> > {
    > >> >> > application.Disposed +=new EventHandler(application_Disposed);
    > >> >> > }
    > >> >> >
    > >> >> > private void application_Disposed(object sender, EventArgs e)
    > >> >> > {
    > >> >> > // close my object here
    > >> >> > }
    > >> >> >
    > >> >> > Thanks in advance.
    > >> >> >
    > >> >> > --
    > >> >> > Simone Busoli
    > >> >>
    > >> >>
    > >> >>
    > >>
    > >>
    > >>

    >
    >
    >
     
    =?Utf-8?B?U2ltb25lIEJ1c29saQ==?=, Jan 4, 2006
    #7
    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. SS
    Replies:
    2
    Views:
    454
    Trond-Eirik Kolloen
    Jul 3, 2003
  2. Billy

    implement dispose method

    Billy, Nov 12, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    2,716
    Scott M.
    Nov 13, 2003
  3. Antonio Concepcion
    Replies:
    3
    Views:
    2,734
    Antonio Concepcion
    Feb 17, 2005
  4. Sharon

    Dispose called twice

    Sharon, Feb 28, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    508
    Sharon
    Feb 28, 2005
  5. =?Utf-8?B?UGhpbGlw?=

    IHttpModule Dispose

    =?Utf-8?B?UGhpbGlw?=, May 18, 2007, in forum: ASP .Net
    Replies:
    8
    Views:
    1,628
    =?Utf-8?B?UGhpbGlw?=
    May 18, 2007
Loading...

Share This Page