Click here to Skip to main content
15,883,876 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
i'm getting error from this Code.
i'm not getting the context.Request value. it will return null.
ajax always return Error function only.
How to solve this!

JavaScript
$.ajax({
type: "POST",
url: "Handler/Handler.ashx",
data: {TextOne:'Test',TextTwo:'Testing'},
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {alert("Success : "+result);},
error: function (err) {alert("Error : "+err);}
});



C#
<%@ WebHandler Language="C#" Class="Handler" %>
using System;
using System.Web;
public class Handler : IHttpHandler {
 public void ProcessRequest (HttpContext context) {
  string Data1 = context.Request["Test"];
  string Data2 = context.Request["Testing"];
  if(Data1 == Data2)
    context.Response.Write("Success Message");
  else
    context.Response.Write("Success Message");
}
 
public bool IsReusable {
 get {
  return false;
  }
 }
}


Please identity the mistake.
Posted

1 solution

C#
string Data1 = context.Request["Test"];
string Data2 = context.Request["Testing"]

Change the above 2 lines to
C#
string Data1 = context.Request.Params["TextOne"];
string Data2 = context.Request.Params["TextTwo"];
 
Share this answer
 
v2
Comments
PrabhuMuthusamy 11-Feb-13 6:23am    
now also i'm getting null value only.
Renju Vinod 11-Feb-13 6:36am    
Hi,
I have updated the solution please check now.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900