.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

HTTPHandler -> Session_End

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :ASP.Net

I am using Httphandler to access my pages. Have Loginstatus Control on the master pages.

OnLoggingOut for the Loginstatus control I am doing a Session.abandon()... But My session_end

does not get called in the Gobal.asax.


I tried link button and everything.  but when I take out the httphandler the Session_end gets executed in global.asax


Does anyone have any idea how to go around it? I can handle the full session end on my own but is there any way to call Session_end in global.asax?


thanks for any help in advance.


View Complete Post

More Related Resource Links

Will Session_End event will be fired evenif somebody directly closes browser without sign out?

Hi,     In one of my application I m using InProc session state.Can anybody tell me if user closes the browser directly,then Session_End will be called? Regards, Mehul

To use session_end or application_end ?


HI All,

I have a web page where users can add multiple attachments one by one and files should be shown in a gridview and should be opened on file name click. Now, to show the files, or to download the files, i have to store those files on the server.

So, I am creating a folder with random guids as the name and saving all the files added by the use in that folder.

Till this its fine, now the question is I want to delete this temparory folder after I save the data to database. I am doing that on save click, but what if the user closes the browse or navigates to other page without saving ?

Should I add the deleting folder code in session_end or application_end ? How application_end works, as not able to debug this event.



Session_end event raised even open a different browser? vs2010,webform


Session_End in Global ASAX: Is the Session still there until Session_End completes?


I'm trying to do some "housecleaning" with my application.  When the Session_End event fires, I'm wondering, is the Session still there?  Does the Session disappear AFTER the Session_End event completes, or is it gone beforehand?  In other words, can my Session_End event call subroutines that rely on the Session variables?  I'm wanting to log the fact that a particular session ended.  Can I do this in global.asax? 

Is there a way to access the Session object during the Session_End event?


I've tried, but all of my Session variables are coming up as Nothing when the Session_End event is run.  I'm trying to update log files to reflect that a session either timed out or was abandoned, but I'm not having any luck.  Has anyone else done something like this before?  If so, how?  At the very least, I'd like to be able to log the SessionID.

Suggestions are welcome!



Hello friends,

                   I am new to .net, i am facing some problem in session_end event.Actually i am creating one chat application in which owner(Support user) can chat with multiple users(clients).For this i am poping new windows for the owner,so that owner can chat with different clients.On this popup window i am having one button to close the chat,which calls a function on aspx.cs page which calls session.abandon() function.After this it calls Session_End funtion.

My problem is that once the session_end ends,it automaticaly calls this method again and again, i dnt know why...

HttpHandler works with Visual Studio Development Server debugging, but not otherwise


Hi all,

I'm new to HttpHandlers.  I am writing an HttpHandler that reads uploaded files directly from the request stream to provide progress that can be queried using an AJAX request.  For large files, this seems to be faster than having ASP.NET load the file contents into Request.Files and then streaming the file from there to wherever it goes (Linq to SQL into a VARBINARY column in an SQL Server database.)

My HttpHandler works perfectly when I'm debugging using the Visual Studio Development Server, but doesn't work otherwise.  The application pool for this application in IIS 7 is set to run in Classic Mode, and the Handler Mappings screen in IIS says that I must manage managed handlers in system.web/httpHandlers. 

I set up in my applications Web.config file.

<add verb="GET,POST" path="*.upload" type="Namespace.For.UploadHandler, AssemblyForUploadHandler"/>

It works great, so long as I don't debug with the "Use Local IIS Web server" option.

What else do I need to do to get this to work?


spoofing a Page in the httpHandler.



I'm trying to spoof a System.Web.UI.Page in my httphandler, and while this works to some degree.. the "page" needs some added query strings to make this complete. Note below that I'm passing in a virtual path to the Page instance. Can anyone help? I tried adding the query strings to the p.Request object after the Page instance has been instantitated, but I believe the error is -- "Request is not available in this context"

Page p = (Page)BuildManager.CreateInstanceFromVirtualPath(virtualUrl, typeof(Page));

IHttpHandler handler = p;


Generate rss feed with HTTPHandler





I'm looking for link/tutorials/code samples on How to create HttpHandler for generating rss feeds for a website.




URL Routing and Existing HttpHandler problems


Hello everyone,

I have a problem:

I am currently using 2 features: 

1. HttpHandler

Registering the path="res.aspx" verb="*"

2. URL Routing:

Registering with this pattern: "Company/Edit/{*companyId}","~/CompanyEdit.aspx"

In my CompanyEdit.aspx page, I used httphandler res.aspx to generate some images at client.

  • res.aspx?img=1
  • res.aspx?img=3

Now the problem is here, the page is load success with companyId = "12345", but when the images was loaded at client, it loaded the CompanyEdit.aspx again and show error with wrong id.  

I have debug and find the problem that because when image's urls were generated to client with url=res.aspx?img=1, url=res.aspx?img=3, the asp.net will understand that they are Company/Edit/res.aspx?img=1, Company/Edit/res.aspx?img=3 when it maps with URL Routing pattern.

=> So the CompanyEdit.aspx was load again with wrong id (id now is "res.aspx"). 

So, do you have any ideas to solve this problem, or other design.

Thanks, and best regard

httphandler(.ashx) to an (.aspx) page

How To  Redirect from httphandler(.ashx)  to an (.aspx) page in the same application ? http://forums.asp.net/t/1598111.aspx    can some expert confirm better approach

HttpHandler - Sharepoint 2010

Hello, I hope someone can help me. I've inherited an application from a previous employee. The handler works completely fine in SP2003 and SP2007 installations, but when I've tried to get it working within SP2010 to no avail. I'm getting the error: "There was an error trying to locate the requested file: http://localhost/DocCenter/Documents/dddd.tvx Init: The given key was not present in the dictionary."  In SP2003 and SP2007, the httphandler was put in the <httphandlers> section of web.config. For me to get this error, I put the handler under <handlers> in the SP2010 web.config as it just doesn't seem to execute under httphandlers.   Any advice on where I may be able to research/find the solution to get it running under SP2010?   Cheers!

Using HttpHandler for Images - cannot print images from IE Browser



I'm using an HttpHandler to display images from memory ... which is working fine.

The image is displayed as a .png format in a popup window.

My problem is printing the image from IE7 Web Browser using the popup menu displayed after doing a right-click, selecting 'Print Picture'.

A blank page is being printed ... i.e. No Image, just the url and date on the bottom of the page and the page number on the top.

I have also tried this with the image formatted as .jpg, with the same result.

Neither 'Print Picture' or 'E-mail Picture' is working properly.  With E-mail, an email is created, but no image.

Interestingly, 'Save Picture' and "Set as Background' both work fine.

The Image Control's ImageUrl="~/ImageHandler.ashx"

The code used to update the image in the ImageHandler is located in the ProcessRequest function:


// PNG Images are 'special'  You cannot save PNG images directly into the output stream.
// Instead you need to write the image first inot a memory stream;

System.IO.MemoryStream ms = new System.IO.MemoryStream();

context.Response.ContentType = "image/png";

httphandler for image thumbnail IIS7 Integrated



Does any one know any httphandler for image thumbnail generation which could be used with IIS 7 Integrated Mode /.Net 4

I found some handlers but most of them do not work fine with IIS 7 Integrated Mode. (I can't define them in httphandler System.Webserver section in webconfig.

How we register httpmodules and httphandler


Say I am implementing a HttpModule called my_httpmodule and the class is in \App_Code\myModules folder, do I need to change anything in web.config?

How to process scriptResource + WebResource in httphandler


I have a httphandler (scripts.ashx) which combines all javascript files into 1 file and feeds the client this 1 file, instead of a 15 differt javascript files. This is working fine, however my scriptmanager (and whatelse) is also creating scriptresources and webresources (I have 9 of those) and also I have a javascript-enabled webservice, which also generated a javascript file.

I would like to include these 10 files in the httphandler I use to create 1 large javascript-file.

Anyone has an idea how I can get these scriptresources/webresources processed in the httphandler, so they don't have to be generated seperately anymore ? (Having 1 file instead of 25)

Thanks in advance,


Imports System.Web
Imports System.IO
Imports System.IO.Compression

Public Class Script : Implements IHttpHandler
    Private cache_duration As TimeSpan = TimeSpan.FromDays(30)
    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
        Dim encoding As UTF8Encoding = New UTF8Encoding(False)
        Dim ms As New MemoryStream()
        Dim jsFiles As New List(Of String)
        If HttpContext.Current.Request.QueryString("type") = "" Then      

Large files over httphandler and IIS7 or of memory



I have a problem with large respones and IIS7, the server runs out of memory.

I've written the test code below that works pretty much like my real code... When i start to download the file i can se the memory usage rise until it hits 100% and Firefox complaints about lost connection to server, looks like IIS7 does not release cache or something.. Works in IIS6 by the way...

Thanks in advance, Anders

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Threading;

namespace HttpHandlerTest
    public class FileHandler : IHttpHandler
        public bool IsReusable
            get { return true; }

        public void ProcessRequest(HttpContext context)
            int buffSize = 8192;
            int itterations = 1024 * 500;

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend