小编Tri*_*dus的帖子

提取HTTP POST数据(WCF C#)

如何在我的WCF服务中收到的HTTP POST请求中获取数据?

我使用HTTP POST从另一个服务发送数据:

        string ReportText = "Hello world";

        ASCIIEncoding encoding = new ASCIIEncoding();
        byte[] data = encoding.GetBytes(ReportText);

        // Prepare web request...
        String serverURL = ConfigurationManager.AppSettings["REPORT"];
        HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(serverURL);
        myRequest.Method = "POST";
        myRequest.ContentType = "application/x-www-form-urlencoded";
        myRequest.ContentLength = data.Length;
        Stream newStream = myRequest.GetRequestStream();

        // Send the data.
        newStream.Write(data, 0, data.Length);
        newStream.Close();
Run Code Online (Sandbox Code Playgroud)

但是当我在WCF中收到POST请求时,我找不到使用WebOperationContext.Current.IncomingRequest提取它的方法,如何从HTTP POST请求中提取数据?

c# post http

2
推荐指数
1
解决办法
8798
查看次数

标签 统计

c# ×1

http ×1

post ×1