Sample Application on HttpClient with .NET core
I want to send a Http request to some website(URL) and get a response(Basically i need to use GetAsync and PutAsync methods for this) and i need to do with .NET Core in vs2015. Since i am new to .NET Core, i am unable to do it on my own and i didn't find good useful links that address my need. Can anyone set me on the path by providing sample applications or useful links ?Thanks in advance. P.S. I tried randomly some console application(Not sure if it is correct) but when i am adding Microsoft.Net.Http dependency to the project.json, i am getting an error like This dependency cannot be supported on .NET Core framework.
Use System.Net.Http.HttpClient in System.Net.Http instead.
cc: @himadrisarkar
Hi @sravan1022 , have you downloaded the SDK from here? https://www.microsoft.com/net/core#windows. See the "Visual Studio Users" link.
If so, the best way to start would just be to create a new project with the Console Application (.NET Core) template, which should be installed from the above link. Once the project is created and opened, you should be able to use HttpClient.
Hi, @mellinoe It's my fault that i should not updated the source of the Package Sources in Package manager Settings. Now i am successfully able to use System.net.Http. The problem now is, i added Microsoft.AspNet.WebApi.Client since it adds support for formatting and content negotiation to system.Net.http but this dependency does not support framework .NETCoreApp,version=v1.0 What should i do now ? @antiufo hey System.net.http worked !!
@sravan1022 Sorry, I'm not familiar with this component (Microsoft.AspNet.WebApi.Client). But it's possible that you're actually trying to use a component that doesn't work on .NET Core. You will probably have better luck asking the folks over in https://github.com/aspnet/home, they will know more about that component and could probably point you to a version that works with .NET Core (or a replacement).
thanks for the help !! I am closing this issue here and opening in asp.net core Track it here https://github.com/aspnet/Home/issues/1558
Hi Sravan,
I'm also working on the same thing, I would like to know if you have completed your task. i'm also stuck in the same place where you were. I would really appreciate if you can help me out with this issue. If you can give me a reference of how you solved it.
Thank You!
I look forward for your response.
Best regards,
Sandeep
https://docs.microsoft.com/en-gb/dotnet/api/system.net.http.httpclient?view=netcore-1.1
and also
https://github.com/Quobject/CoreFxHttpClientHandlerTest/blob/master/CoreFxHttpClientHandlerTest/Program.cs