找传奇、传世资源到传世资源站!

android与webapi交互_

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

web api 服务器端写法


        [HttpPost]
        [ActionName("Simple")]
        public string GetName([FromBody]string value)
        {
            string userName = value;
            HttpContent content = Request.Content;
            return "dddd";


        }

        [HttpPost]
        [ActionName("StringSingle")]
        public HttpResponseMessage GetUserEmail([FromBody]User value)
        {
            var response = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent("zhangjie")
            };
          
            if (value != null)
            {
                //User user = new UserHelper(this.context).GetUser(value.UserName);
                //return user.Email;
              
                response.Headers.Location = new Uri("http://www.baidu.com");

                response.Content = new StringContent("http://www.baidu.com" value.UserName);
                return response;
            }
            else
            {
          
                response.Headers.Location = new Uri("http://www.google.com");
                response.Content = new StringContent("http://www.google.com");
                return response;
            }
        }

        [HttpPost]
        [ActionName("Single")]
        public User GetUser([FromBody]User value)
        {
           

            if (value != null)
            {
                User user = new UserHelper(this.context).GetUser(value.UserName);
                return user;
            }
            else
            {

                return null;
            }
        }

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复