国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
成功后臺(tái)調(diào)用webapi

using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Net.Http;

using System.Web.Http;

namespace templates.Controllers

{

    public class DefaultController : ApiController

    {

        // GET api/default

        public IEnumerable<string> Get()

        {

            return new string[] { "value1", "value2" };

        }

        // GET api/default/5

        public string Get(int id)

        {

            return "value";

        }

        // POST api/default

        public string Post([FromBody]Class1 cla)

        {

            return cla.i + cla.str;

        }

        // PUT api/default/5

        public string Put(int id, [FromBody] Class1 cla)

        {

            return cla.i + cla.str;

        }

        // DELETE api/default/5

        public string Delete(int id)

        {

            if(id > 0)

            {

                return "完成刪除操作";

            }

            return "失敗";

        }

        public string testa(int id,string a)

        {

            return a;

        }

    }

}

protected void Page_Load(object sender, EventArgs e)

        {

            string ss = HttpPost("http://localhost:38477/api/Default/888", "{i:32,str:\"test1\"}");

            Response.Write(ss);

        }

        public static string HttpPost(string url, string body)

        {

            //ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);

            Encoding encoding = Encoding.UTF8;

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            request.Method = "POST";

            request.Accept = "text/html, application/xhtml+xml, */*";

            request.ContentType = "application/json";

            byte[] buffer = encoding.GetBytes(body);

            request.ContentLength = buffer.Length;

            request.GetRequestStream().Write(buffer, 0, buffer.Length);

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))

            {

                return reader.ReadToEnd();

            }

        }

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
利用百度AI開放平臺(tái)進(jìn)行本地圖片通用文字識(shí)別
淺析C# HTTP Request請(qǐng)求程序模擬 - 51CTO.COM
.NET Web API之filter ActionFilterAttribute 過濾器使用
Asp.Net MVC及Web API框架配置會(huì)碰到的幾個(gè)問題及解決方案
C# HttpWebRequest 絕技
使用HTTP POST請(qǐng)求12306網(wǎng)站接口查詢火車車次API
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服