I need to post form data using jQuery AJAX.
the form is made up of some input text, i.e.: firstname, lastname, age
I post to an ASHX file and I'd like to read them directly like a Request.Form["firstname"] and not by building a class, serialize object etc... like is generally done with JSON post
is it possible to that?
I'm not sure of your use case to consider this approach but here is how you could achieve it. In the ProcessRequest method of the Handler class in the ashx code behind file,
public void ProcessRequest (HttpContext context) {
var formData = context.Request.Form; // Get the form object from the current HTTP request.
foreach(var formVariable in formData)
{
var value = formData[formVariable];
}
}
I hope this would help in your case!