Avatar of Larry Brister
Larry Brister
Flag for United States of America asked on

Get POST to .Net C# ASHX Generic Handler page

I am posting data to a ashx page
http://wcf.mydomain.com/Person.ashx/Person
(Actually http://wcf.mydomain.com/Person.ashx?person=myjsonstring)
The code for the page is below.

I want to just be able to post to the form without a "QueryString" for the person posting

AND

On my handler grab what was posted

Right now... my code works if I set a query string parameter of "person" and post to that
<%@ WebHandler Language="C#" CodeBehind="~/App_Code/Person.cs" Class="Person" %>

using System;
using System.Web;
using System.Web.Script.Serialization;
using System.Data;
using System.Collections;

public class Person : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        try
        {
        
          //SOMETHING NEEDS TO CHANGE HERE??????
            string value = context.Request.Form.ToString();

            context.Request.ContentType = "application/json";
            context.Response.ContentType = "application/json";
            JavaScriptSerializer jsSerializer = new JavaScriptSerializer();
            //Persons person2 = jsSerializer.Deserialize<Persons>(context.Request.Form["person"]);
            context.Response.Write("200: " + value);            
        }
        catch (Exception ex)
        {
            context.Response.Write("ERROR: " + ex.Message + "|||" + ex.StackTrace);
        }
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}

Open in new window

Web ServicesC#.NET Programming

Avatar of undefined
Last Comment
Larry Brister

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
ste5an

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Larry Brister

ASKER
Oh man.... YES!
Remind me to buy you a sody-pop sometime!
Seriously... this was something I had NO idea about.  Life-saver for sure.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes