Here's my sample implementation of ASP.NET connecting to a Generic Handler.
my WebForm1.aspx.cs code
public partial class WebForm1 : System.Web.UI.Page
{
public string myCurrentUser = "MyUser";
public string myCurrentUserID = "1";
protected void Page_Load(object sender, EventArgs e)
{
}
}
Sample ASP.NET page.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
<!--note that you need to have an updated jquery version here..-->
<script src="jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
var PassValues = "?User=" + "<%=myCurrentUser%>" + "&ID=" + "<%=myCurrentUserID%>"
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Handler1.ashx" + PassValues,
success: function (data) {
alert(data);
},
error: function (err) {
var str = err;
}
});
});
</script>
NOTE: Ensure that the $.AJAX URL PATH of the Handler is correct

my Handler1.ashx.cs code
public class Handler1 : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write("Hello User <" + context.Request.Params["User"] + "> with ID <" + context.Request.Params["ID"] + ">");
}
public bool IsReusable
{
get
{
return false;
}
}
}