Solved

Get POST to .Net C# ASHX Generic Handler page

Posted on 2016-07-15
2
131 Views
Last Modified: 2016-07-15
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

0
Comment
Question by:lrbrister
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 34

Accepted Solution

by:
ste5an earned 500 total points
ID: 41712893
"I want to just be able to post to the form without a "QueryString" for the person posting"

You haven't posted an example of this, the consumer side, but just don't add a QueryString.
0
 

Author Closing Comment

by:lrbrister
ID: 41713204
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.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question