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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

HTTP Handler ProcessRequest only Fires First Time

Posted By:      Posted Date: September 20, 2010    Points: 0   Category :ASP.Net

I have a JavaScript method which is called whenever a modal window closes. The JavaScript method calls an HTTP Handler to run a server side function. When I close the window the first time, the code behind runs. When I close it a second time, I can see the JavaScript method run, I am getting an XMLHTTPRequest object, but the code behind does not run again. What am I missing? Thanks.


            function createXMLHttpRequest() {
                try { return new XMLHttpRequest(); } catch (e) { }
                try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { }
                try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { }
                return null;

            function ClearDocumentSession() {

                var xmlHttpReq = createXMLHttpRequest();
                xmlHttpReq.open("GET", "http://localhost:56331/Handlers/AjaxHandler.ashx", false);


The handle

public class AjaxHandler : IHttpHandler, IRequiresSessionState

        public void ProcessRequest(HttpContext context)
           //  context.Response.ContentType = "text/html";

View Complete Post

More Related Resource Links

Attempting to use an HTTP handler to display pictures in gridview. It's not working, please help.

I am writing a web page that needs pictures displayed for each item.  The page works just fine except for the pictures.  I have a file called handler.ashx uploaded to the server as well.  It does not seem to be hurting anything, but it doesn't seem to help display the pictures either!  I am working with a MySQL database so I am thinking that the call for the data or the ashx page's structure itself are my problem.  I am using C# Express so there is no generic handler class to autoload and therefore my handler page is pasted together and I know the using statements are in the wrong place, but I'm new to this and I'm lost!  The following is my database table info (table is named: Yamaha), my handler.ashx page code, and the code for the final web page.  I have loaded ".jpeg" or "jpeg" into the field I added called "Image_Type"  since I have already uploaded all pictures as longblobs.  You can view the final web page here: http://www.88867honda.com/YamahaPtsSale.aspx Thanks in advance for any help, Melissa   Table info: Field TypeAttributes--> Null DefaultExtra--> Comments part_number varchar(15)  --> No     -->   description varchar(50)  --> Yes  NULL   -->   qty int(4)  --> Yes  NULL  

HTTP Handler IIS Compression

I am using a IHttpHandler to write a PDF file to the output stream in IIS 7 with ASP.NET 4 RC as follows.context.Response.WriteFile(pdfFilePath) context.Response.Flush() I am aware that IIS 7 offers both static and dynamic compression which is configured using the urlCompression and httpCompression elements in their respective config files. This works well except for with the output of IHttpHandlers. It seems their output is not being compressed even though I have enabled dynamic compression and added the IHttpHandler's mime-types (application/pdf in this case) to the dynamicTypes section.Why are my IHttpHandler's output not being compressed by IIS? I'm aware I could do this manually in the handler but I'd rather let IIS do it.Thanks,Eric

threading timers fires few seconds before the actual due time



We're getting following problem while using system.threading.timer ( .net framework 2.0 ) from a Windows service.

There are around 12 different timer objects..
Each timer has due time and interval. This is set correctly.
It is observed that after 3 to 4 hours, the timers start signalling before their interval elapses. For example if the timer is supposed to signal at 4:59:59, it gets signalled at 4:59:52, 7 seconds earlier.
Can someone tell me what is the cause for this behavior and what is the solution for that ?

Thanks, Gayatri

IIS 7.5 - HTTP Error 404.17 - Not Found - Static File Handler.


 I'm having an issue with web.config file in my development environment. I had the WCF site running on my local. My local has VS2010 framework 4.0 installed. I published the code and hosted the site in IIS 7.5 2008 R2 on my dev server which has an application pool of framework 2.0. I had an issue which says

HTTP Error 404.17 - Not Found

The requested content appears to be script and will not be served by the static file handler.


These are the few handlers that i've in my web.config file on my dev server. There are other handlers too which are inherited.


      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

HTTP Handler Problem


<img alt="httpHandler" src="getImage.ashx?id=1">

works fine

<asp:Label ID="sd" Text='<%# "getText.ashx" %>' runat="server"></asp:Label>

i have written httphandler which will display text of a label but processrequets of httphandler event is not being fired.

any help plese.

Files won't download from ASP.NET site when the site has a custom HTTP Handler mapped to the file e


When I have a HttpHandler class in C#/ASP.NET mapped to a file extension in IIS any file with that extension fails to download/display in web browsers (it's downloaded as a 0-byte file in some browsers and nothing at all in other browsers).  After removing the application mapping for the HttpHandler in IIS so it doesn't call the IHttpHandler class in C#, the web browser downloads the file successfully.

This was tested with an IHttpHandler class in C# that has an empty ProcessRequest method. Any ideas on what the problem could be?

Response Content Type can not be set within Http Handler


as the subject, i have a handler that process all kind of request to the server (path="*"),

whenever i try to set the content type, it will be overridden by a default value "text/html",

i am using IIS7 + Framework 4  in integrated mode, any idea?

When to use HTTP-Handler ?


Hi Guys,

Can you please explain me when to use HTTP Handlers ? What scenarios we may need HTTP Handlers ?

Thanks in advance.

Round off time to the nearest minute

How would you round this up to the nearest minute? There isn't a built in function to do this so you have to use a little bit of maths to get there. There are 60 seconds in a minute. We already have 38 seconds on the clock. So we need to add on 60 - 38 = 22 more seconds.

ASP.NET Architecture - ASP.NET Worker Process - HTTP Pipleline - Http Modules and Handlers

"ASP.NET is a powerful platform for building Web applications, that provides a tremendous amount of flexibility and power for building just about any kind of Web application. Most people are familiar only with the high level frameworks like WebForms and WebServices which sit at the very top level of the ASP.NET hierarchy. In this article I'll describe the lower level aspects of ASP.NET and explain how requests move from Web Server to the ASP.NET runtime and then through the ASP.NET Http Pipeline to process requests.

Performance Tests: Precise Run Time Measurements with System.Diagnostics.Stopwatch

Everybody who does performance optimization stumbles sooner or later over the Stopwatch class in the System.Diagnostics namespace. And everybody has noticed that the measurements of the same function on the same computer can differ 25% -30% in run time. This article shows how single threaded test programs must be designed to get an accuracy of 0.1% - 0.2% out of the Stopwatch class. With this accuracy, algorithms can be tested and compared.

Date and Time Functions in SQLSERVER

Date and time functions allow you to manipulate columns and variables with DATETIME and SMALLDATETIME data types.

1 DATEPART Function
2 DATENAME Function
3 DAY, MONTH, and YEAR Functions
5 DATEADD Functions
6 DATEDIFF Function
7 More SQL Server Functions

Data Types - Date and Time in SqlServer

Date and time values can be stored with either the DATETIME or SMALLDATETIME data type. The difference between the two is that SMALLDATETIME supports a smaller range of dates and does not give the same level of precision when accounting for time. The DATETIME data type can hold values from January 1st of 1753 to December 31st of 9999. The time is stored to the 1 three hundredths of a second and each value takes up 8 bytes of storage. The SMALLDATETIME data type can hold values between January 1st 1900 and June 6th of 2079. The time is tracked to the minute and each value takes up 4 bytes of storage. The majority of business applications can live happily with SMALLDATETIME, however, if you are in an environment where each second matters or you need to make estimates to the distant future (or past) then you have to resort to DATETIME. If you fail to specify the time when inserting a value into a DATETIME or SMALLDATETIME column, a default of midnight is used. If you fail to specify the date portion the default of January 1, 1900 is used.

How to programmatically add controls to Windows forms at run time by using Visual C#

Create a Windows Forms Application
Start Visual Studio .NET or Visual Studio 2005 or a later version, and create a new Visual C# Windows Application project named WinControls. Form1 is added to the project by default.
Double-click Form1 to create and view the Form1_Load event procedure.
Add private instance variables to the Form1 class to work with common Windows controls. The Form1 class starts as follows:

.NET 4 Web Application Startup Time

I was chatting with Jonathan Hawkins and some of the folks on the ASP.NET team about performance and Jonathan mentioned the startup time for large ASP.NET applications is improved on .NET 4. There are some improvements in the CLR and in ASP.NET itself that helped. If you have a giant app, you should do some tests.

Built-in Functions - Date and Time Functions

Date and time functions allow you to manipulate columns and variables with DATETIME and SMALLDATETIME data types.
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