Using HttpClient in a Xamarin core project

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 04:04:52

I recommend checking out ModernHttpClient https://github.com/paulcbetts/modernhttpclient

It is a cross-platform networking library for iOS and Android. From the project:

This library brings the latest platform-specific networking libraries to Xamarin applications via a custom HttpClient handler. Write your app using System.Net.Http, but drop this library in and it will go drastically faster.

You should be able to use System.Net.Http in your core library just fine, I've done it recently.

Make sure your core library is a .Net 4.5 project. There is a setting in project options for selecting the .Net version. After checking this, all you should have to do is reference System.Net.Http.dll.

If that doesn't solve your issue, are you on Windows or Mac(Xamarin Studio)?

I'm afraid you can't use HttpClient on Mono at the moment due to licensing restrictions. There is a UserVoice suggestion that you can vote on if you like.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!