What is HttpHandler

An HttpHandler is a class that handles HTTP requests. In ASP.Net a Page class, for example, is the default HttpHandler for files with a .aspx extension. You can map different file extensions to different HttpHandlers in ASP.Net. When the web server receives a request for a file, it looks in its configuration to find out whether a special HttpHandler has been designated for that file extension. ASP.Net provides the HttpHandler class to extend the functionality of ASP.net to be able to handle requests for other file types (extensions). In IIS, you make ASP.Net the HttpHandler for the type of file that you desire, and use the web.config file for your web to identify what DLL (Class Library) is used to handle specific file extensions. The HttpHandler is a class that handles the request. It has access to the same HttpContext (Request, Response, Cookies, Session, Application, Server, etc) that the Page class does. For more detailed information, see: HttpHandlers

Will my session state be saved when my page hit an error? Will my session state be saved when my page hit an error? In Session_End, I tried to do some cleanup job using SQL but it failed. Why?

Session_End is supported only in InProc mode. Session_End is run using the account which runs the worker process (aspnet_wp.exe), which can be specified in machine.config. Therefore, in your Session_End, if you connect to SQL using integrated security, it will use that worker process account credential to connect, and may fail depending on your SQL security settings.