locked
Accessing Data in Httphandler sent using post request RRS feed

  • Question

  • User-849503431 posted

    Hello friends

    I have created a httphandler. Everything is working fine If you take the request type GET. But I really don't want GET request due to security reasons.

    I am making a POST request using Jquery using following code

    $.ajax({
                type: "POST",
                async: false,
                url: "SaveAccounts",
                data: { a: "Sent Data" },
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function OnSuccess(a) {
                    alert(a);
                },
                error: function OnError(request, status, error) {
                    alert('Error: ' + request + ' ' + status + ' ' + error);
                },
                complete: function () {
    
                }
            });

    And the code for processing request is:

            context.Response.ContentType = "application/json; charset=utf-8"
            Dim s As String = context.Request.Params("a")
            context.Response.Write(JsonConvert.SerializeObject(s))

    This code is returning 'null' in javascript alert in client side.

    Please note every thing is working fine when request type is changed to GET in $.ajax() function.

    I have also tried to access posted data using context.Request.Form("a") and context.request.SserverVariables("a")

    context.request.Params is a combined collection of 'Form', 'ServerVariables', 'Cookies' etc.

    Please tell me where I am going wrong...??

    Thanks for looking....

    Thursday, September 29, 2011 11:22 AM

Answers

  • User-849503431 posted

    It is working if I do remove contentType and dataType specification from request. And everything other than this will remain same.

    It is very bad that no one could answer this my stupid question.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 2, 2011 2:37 AM