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

Top 5 Contributors of the Month
Post New Web Links

what is httphandler

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :ASP.Net


       Can anyone explian to me please what is httphandler and where do we use it.  or provide me any usefull links from where I can read more about it.  thanks in advance.

View Complete Post

More Related Resource Links

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;

HTTPHandler -> Session_End


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.


Add ReportViewer httphandler and entire website errors


I have a site thats working fine - I added a page with a reportviewer control and get the error message

The Report Viewer Web Control HTTP Handler has not been registered in the application's web.config file.  Add <add verb="*" path="Reserved.ReportViewerWebControl.axd" type = "Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> to the system.web/httpHandlers section of the web.config file.

I added this to the system.web section of web.config, and when I do - the entire site no longer works, I get a "500 - Internal server error." 

The web.config currently reads:

<?xml version="1.0"?>
		<add connectionString="Server=server;
         User ID=user;
         Password= password" 

Communication between Page and HttpModule/HttpHandler


I have a third-party client-side control that can execute "URL actions" that send a request back to the server.  I'd like to be able to intercept the incoming request and use the event to update an UpdatePanel in my existing page rather than doing a postback to launch the new page.  I've looked at httpModules and httpHandlers - it seems there should be a way to raise a custom event (from an HttpModule/Handler) that my page could use to deal with the update panel.  I could then discard the request so that it doesn't cause a postback, but that's where I get lost in the ether.
Is there a good, accepted way to do this?


I have a third-party client-side control that can execute "URL actions" that send a request back to the server.  I'd like to be able to intercept the incoming request and update an UpdatePanel in my existing page rather than doing a postback to launch the newly requested page.  I've looke

How to write a httphandler and change all image paths


Hello. what i want is pretty easy .

my all image paths are relative atm. so they are getting processed like this




what i want is to convert all image paths to this with image http handler




static.pokemoncraft.com domain is cookieless

so this will reduce http headers size and increase performance


i think this should be pretty easy

thank you


How to avoid session timeout in HTTPHandler


How do I avoid ASP.NET session timeout from a httphandler?

HttpHandler and Default Document IIS7



I need to figure out how to inherit the default aspx httpHanlder or figure out how to handle the default document.


I have written an httpHandler that will append a querystring to the end of a request if it doesn't exist. This works great.

The problem is that the default page specified in IIS do not work.  If i enter url like:


then it processes correctly.  If on the otherhand I enter:


I get a blank page because the http handler isn't redirecting based on the list in IIS.  I've tried multiple things. I've tried to inherit the DefaultHttpHandler but I think that is wrong because I can't use that with integrated mode.  Maybe I need to handle this in an httpModule but it seems the closes to the request, to change and redirect a url should be in a handler.

Any help would be greatly appreciated. 

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