在 ASP.NET Web API(一):使用初探,GET和POST数据 一文中,跟着接触了一下Web Api,照着教程,竟然也顺利可以用了,感觉蛮好的,哈哈哈。。
程序刚开始运行的时候,会在浏览器里弹出:localhost:30384
1、想要GET的话,将其改为localhost:30384/api/Users 就可以了,结果如下:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
2、POST
这样的话,需要下载Fiddler,原链接里也有下载链接(Fiddler下载地址),问题主要有2个:
(1)Request Headers里那里,我照着评论修改了一下:User-Agent: Fiddler
Host: localhost:30384
Content-Type: text/json; charset=utf-8
Content-Length: 63
(2)Request body那里:
{"UserID":4,"UserName":"Parry","UserEmail":"Parry@cnblogs.com"}
之前复制作者贴出来的东西,Parry@cnblogs.com这里没有用“”括起来,改好点Execute就真的跳到了断点那里,而且执行都OK。。。
谢谢各位,略略知道Web API是个什么东西了,感谢。。。。