General processing procedure (the ashx) acquisition parameters not issue a POST request

Write a generic handler interfaces to do, because the field Content is text, the length may be long, For this reason, it is not a GET request

So the question is, when I changed POST request that he use HttpHelper class to write a Demo

code
var result = new HttpHelper().GetHtml(new HttpItem()
{
    URL = "http://localhost:24885/Comment.ashx",
    Method = "POST",
    Postdata = "action=insert_comment&art_id=1&art_title=文章标题&cid=&uid=1&unick=kerwin&content=你好&type=1&reply_id=&reply_nick=&parent_uid=&parent_nick=&parent_cid=&ip="
});
Modal found

Image

In context.Request [ " Action " ], context.Request.Form and context.Request.QueryString not get all the above Postdata

However, we can see in context.Request.InputStream parameters, InputStream is 156 or the length of the data seen context.Request.TotalBytes

Image

So we can get the parameters with the following code

code
var pams = System.Text.Encoding.UTF8.GetString(context.Request.BinaryRead(context.Request.TotalBytes))
Note: Get the parameters above this line of code can only get one, get the second binary data does not exist

We can be parsed, currently known data are obtained pams json serialized string, at this time we can directly deserialization, but if the request specifies when the Content -Type of application / json; charset = utf8 or is application / x-www-form- urlencoded; charset = utf-8 in this case, not obtained PAMS json serialized string, but contains Boundary resumable

 

Guess you like

Origin www.cnblogs.com/romanticcrystal/p/12047254.html