问题描述
在Mac上的Visual Studio Code中使用ASP.NET 5.我有一个RESTful API,我需要调用它,但不确定到底该怎么做.我已经看到了许多使用WebClient,HttpClient,WebRequest和HttpWebRequest的示例.
Working with ASP.NET 5 on my Mac in Visual Studio Code. I have a RESTful API I need to call and not sure exactly how to do it. I've seen many examples using WebClient, HttpClient, WebRequest and HttpWebRequest.
我认为我的痛点是dnxcore50框架.有人可以通过一些代码示例向我指出正确的方向吗?
I think my pain point is the dnxcore50 framework. Can someone please point me in the right direction with some code samples?
推荐答案
以下是有关如何调用服务的示例.请仔细检查References
和using
.
Here is an example about how to call a service. Please check the References
and using
carefully.
您要做的一件事是安装Web API客户端库软件包:从工具"菜单中选择 NuGet软件包管理器,然后选择软件包管理器控制台.在程序包管理器控制台"窗口中,键入以下命令:Install-Package Microsoft.AspNet.WebApi.Client
.
One important thing you have to do is install the Web API Client Libraries package: From the Tools menu, select NuGet Package Manager, then select Package Manager Console. In the Package Manager Console window, type the following command: Install-Package Microsoft.AspNet.WebApi.Client
.
有关完整的源代码,请检查此链接.
For the full source code, check this link.
这篇关于如何使用ASP.NET 5调用RESTful API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!