ASP.NET Advanced Generic Handler ASHX Introduction

Generic handlers are the .NET component, In general generic handlers have an extension of ASHX.
I see a lot of people using pages to process AJAX requests when we can use this much less expensive endpoint. This is an completely worked out Generic Handler that truly knows how to handle your http (AJAX) requests.
Using the code-
1-Create a new Generic Handler
2-Clear everything inside the handler class
3-Inherit from my Handler class
4-DONE! Now you only need to add your methods.


<!DOCTYPE html>
<html xmlns=””&gt;
<!– Include your Jquery file here –>

function SaveTextBoxData() {
var objData = new Object();
objData.userPass = $(“#txtname”).value;
cache: false,
type: “POST”,
url: “../Handler1.ashx?ACTION=savenamedata”,
data: objData
}).done(function (data) {






<%@ WebHandler Language=”C#” Class=”Handler1″ %>

using System;
using System.Web;

public class Handler1 : IHttpHandler {
public void ProcessRequest(HttpContext context)
string retvalue = “”;
string ACTION = context.Request.QueryString[“action”];
switch (ACTION)
case “savenamedata”: retvalue = SaveNameData(context); break;

context.Response.ContentType = “Application/Json”;
public bool IsReusable
return false;
public string SaveNameData(HttpContext context)
string rest=””;
var obj = context.Request.Form;
rest = obj[“userPass”].ToString();

return rest;



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s