Web Api初接触

在 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.
<ArrayOfUsers xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/MvcApplication1.Models">
<Users>
<UserEmail> Superman@cnblogs.com </UserEmail>
<UserID> 1 </UserID>
<UserName> Superman </UserName>
</Users>
<Users>
<UserEmail> Spiderman@cnblogs.com </UserEmail>
<UserID> 2 </UserID>
<UserName> Spiderman </UserName>
</Users>
<Users>
<UserEmail> Batman@cnblogs.com </UserEmail>
<UserID> 3 </UserID>
<UserName> Batman </UserName>
</Users>
</ArrayOfUsers>

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是个什么东西了,感谢。。。。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值