| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4385 人关注过本帖
标题:frombody null
只看楼主 加入收藏
jumjoe
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-2-25
收藏
 问题点数:0 回复次数:0 
frombody null
我的webapi:
  public string Post([FromBody]string value)
        {
            // string order = value.ToString();
            /*
             if (value == "8888")
             {
                 return hotel;
             }
             else if(value == null) {
                 return null;
             }
             return hotel;
            // return hotel;
             //return null;
           */

            return value;

        }


我的post winform程序:

            string reqestMsg = "8888";
            string responseMsg = string.Empty;
            byte[] buffer = Encoding.UTF8.GetBytes(reqestMsg);
            string url = textBox2.Text;
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = buffer.Length;

            using (Stream requestStream = request.GetRequestStream())
            {
                requestStream.Write(buffer, 0, buffer.Length);
            }

            HttpWebResponse resonse = (HttpWebResponse)request.GetResponse();
            Stream responseStream = resonse.GetResponseStream();

            using (StreamReader sr = new StreamReader(responseStream))
            {
                responseMsg = sr.ReadToEnd();
            
                textBox1.Text = responseMsg;
            }

            resonse.Close();
        }
//textbox2.text = "http://localhost:50828/api/gethotellist/";

这个样子,但是传递过去的返回值 一直为NULL,就是传递参数 赋值不了value~求救!!!!
2016-02-25 17:02
快速回复:frombody null
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016192 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved