从调用API接口 看.net framework和 net core的异同
展开全部
请在此输入您的回答
由于.net core是跨平台使用的,所有微软重写好多API,由此有些差异也是正常的。
现在就来看下请求API的差别吧。
首先,原本的.net framework请求方法:
public static T HttpPostWithDecompression<T>(string request, string url, int timeout) where T : new()
{
var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.Proxy = null;
httpWebRequest.Timeout = timeout;
httpWebRequest.Method = "POST";
httpWebRequest.ContentType = "application/json";
httpWebRequest.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
var bytes = Encoding.UTF8.GetBytes(request);
Stream requestStream = null;
由于.net core是跨平台使用的,所有微软重写好多API,由此有些差异也是正常的。
现在就来看下请求API的差别吧。
首先,原本的.net framework请求方法:
public static T HttpPostWithDecompression<T>(string request, string url, int timeout) where T : new()
{
var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.Proxy = null;
httpWebRequest.Timeout = timeout;
httpWebRequest.Method = "POST";
httpWebRequest.ContentType = "application/json";
httpWebRequest.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
var bytes = Encoding.UTF8.GetBytes(request);
Stream requestStream = null;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询