调试WebApi的一些方法

1、Get方法时,直接用浏览器访问

2、Postman

3、用HttpClient调用

privatevoid GetData()
{
    using (HttpClient client = new HttpClient())
    {
        client.BaseAddress = new Uri("ipaddress");
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json")); try { HttpResponseMessage response = client.GetAsync("testapi/getdata?id=0").Result; } catch { } } }

 

posted @ 2018-10-23 13:37  向萧  阅读(1901)  评论(0编辑  收藏  举报