Dispose() on asp.net pages
I have ASP.NET web site and I get a session id from a web service where I am going to use throughout rest of pages. I am passing this session id between pages to peform some action. What I am trying to achieve is that I want to make sure I release this session id from the web service by calling it's logout method when the user closes a page. I am thinking to add Dispose() on each page and call the logout method. Does Dispose() get called when the user closes a page (browser)? Or, how can开发者_开发百科 I call the logout method when a page is closed?
Thanks.
Dispose will get called at the end of each page call, not at the end of the user's session. It sounds to me like you want to use the Session_End event (in the global.asax) to end the web service session. If you call the logout in the page dispose you'll have to login again every time the user loads a new page.
精彩评论