洱吧下载,冯小刚买菜狂砍价,邪恶力量第九季
本示例使用的是.net core2.2版本,微软提供了访问第三方服务的扩展,只需要在startup.cs中添加。
紧接着就是通过di直接使用。示例如下:
using microsoft.aspnetcore.mvc; using system; using system.collections.generic; using system.net; using system.net.http; using system.threading.tasks; namespace demo.controllers { [route("api/[controller]")] [apicontroller] public class valuescontroller : controllerbase { private readonly ihttpclientfactory _httpclientfactory; public valuescontroller(ihttpclientfactory httpclientfactory) { _httpclientfactory = httpclientfactory; } [httpget] public async task<actionresult<string>> get() { var url = @"http://127.0.0.1:8888/demo/test.asmx/save"; dictionary<string, string> dicparam = new dictionary<string, string>(); dicparam.add("id", "1"); dicparam.add("name", "张三"); httpcontent content = new formurlencodedcontent(dicparam); return await remotehelper(url, content); } private async task<string> remotehelper(string url, httpcontent content) { var result = string.empty; try { using (var client = _httpclientfactory.createclient()) using (var response = await client.postasync(url, content)) { if (response.statuscode == httpstatuscode.ok) { result = await response.content.readasstringasync(); } } } catch (exception ex) { console.writeline(ex); } return result; } } }
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Blazor server side 自家的一些开源的, 实用型项目的进度之 CEF客户端
.NET IoC模式依赖反转(DIP)、控制反转(Ioc)、依赖注入(DI)
vue+.netcore可支持业务代码扩展的开发框架 VOL.Vue 2.0版本发布
网友评论