.net Core Ubuntu HttpWebRequest错误:无此类设备或地址

时间:2019-03-25 09:24:10

标签: .net ubuntu asp.net-core .net-core

在我的.net核心项目中,我正在执行标准的Web请求(HttpWebRequest)。 将.net core 2.0更新到2.2后,它开始在ubuntu(docker)上产生错误。 在Windows环境下工作。

错误消息是:没有这样的设备或地址

代码:

HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Headers.Add("SOAPAction", action);
webRequest.ContentType = "text/xml;charset=\"UTF-8\"";
webRequest.Accept = "text/xml";
webRequest.Method = "POST";

var soapBodyString = CustomXmlSerializer.ToXml(request);
var soapEnvelopeXml = utils.CreateSoapEnvolope<TRequest>(soapBodyString, 
typeof(TRequest), ref soapMethodFullName,  options);
InsertSoapEnvelopeIntoWebRequest(soapEnvelopeXml, webRequest);

var response = await webRequest.GetResponseAsync(); // Thrown error here
var responseStream = response.GetResponseStream();
var rd = new StreamReader(responseStream, Encoding.UTF8);
soapResult = rd.ReadToEnd();

0 个答案:

没有答案