views:

67

answers:

1

Anyone know how to access HTTP POST data in the Padarn web server? They wrote the POST data will be in Request.Form, but there is always nothing.

A: 

We'd need to see more of your code. Is this a Page or is it a custom IHttpHandler? What version of Padarn are you using? I just tested the following and it output the POST data as expected:

public class Target : Page
{
    protected override void Page_Load(object sender, EventArgs e)
    {
        Response.Write("<b><u>Request.Form.Keys</u></b><br>");

        Response.Write("<ul>");
        foreach (var key in Request.Form.AllKeys)
        {
            Response.Write(string.Format(
              "<li>Key: '{0}'    Value: '{1}'", key, Request.Form[key]));
        }
        Response.Write("</ul>");

        // flush
        Response.Flush();
    }
}
ctacke
I'm using Version 1.2.10.0. At the moment it's a Page. I POST a JSON-string via jQuery to the Page, when I inspect the sended Httpheader with Wireshark, all is correct. But there is no data in Request.Form, Request.ContentLength has the right size. Is there a chance to get the RAW data? I've tried to Implement the IHttpHandler, but it's ending in a NullReferenceException because I don't find any further examples or docs. I also left a comment at your blog about this.
chriszero
The latest versions are 1.4.x. I don't recall what was (or wasn't) supported back in 1.2, but I'm fairly sure custom IHttpHandlers were not. I'd start by upgrading to the latest and seeing if that takes care of the issues you're seeing.
ctacke
The new version of Padarn solved it. There is also an Request.InputStream now from which I get the RAW content, IHttpHandlers also working. Hopefully my web service getting finished soon =)
chriszero