代码如下,在windows平台上部署好后发送请求可以返回inputStream数据流
但是在linux上部署后出现System.Net.WebException: The request timed out的问题
发现被System.Net.HttpWebRequest请求的文件根本没有被访问
是不是在linux上使用System.Net.HttpWebRequest需要有什么特别的配置呀
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(hostURL);
request.ContentType = "application/x-www-form-urlencoded";
using (WebResponse response = request.GetResponse())
{ using (Stream inputStream = response.GetResponseStream())
{
//向服务器请求,获得服务器回应数据流
int actualSize = 0;
//使用ReceiveStreamData方法把流写入_Buffer(byte[]数组),然后进行输出
ErrorCodes resultRead = ReceiveStreamData(inputStream, _Buffer, out actualSize);
HttpContext current = HttpContext.Current;
if (current == null)
{
throw new ApplicationException("Current System.Web.HttpContext not found - Send failed.");
}
if (!current.Response.Buffer)
{
current.Response.Buffer = true;
current.Response.Clear();
}
inputStream.Close();
response.Close();
current.Response.ContentType = "application/octet-stream";//MIME类型:匹配任意文件类型
current.Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileTrueName, Encoding.UTF8).Replace("+", "%20"));
Response.BinaryWrite(_Buffer);
Response.Flush(); } }
但是在linux上部署后出现System.Net.WebException: The request timed out的问题
发现被System.Net.HttpWebRequest请求的文件根本没有被访问
是不是在linux上使用System.Net.HttpWebRequest需要有什么特别的配置呀
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(hostURL);
request.ContentType = "application/x-www-form-urlencoded";
using (WebResponse response = request.GetResponse())
{ using (Stream inputStream = response.GetResponseStream())
{
//向服务器请求,获得服务器回应数据流
int actualSize = 0;
//使用ReceiveStreamData方法把流写入_Buffer(byte[]数组),然后进行输出
ErrorCodes resultRead = ReceiveStreamData(inputStream, _Buffer, out actualSize);
HttpContext current = HttpContext.Current;
if (current == null)
{
throw new ApplicationException("Current System.Web.HttpContext not found - Send failed.");
}
if (!current.Response.Buffer)
{
current.Response.Buffer = true;
current.Response.Clear();
}
inputStream.Close();
response.Close();
current.Response.ContentType = "application/octet-stream";//MIME类型:匹配任意文件类型
current.Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileTrueName, Encoding.UTF8).Replace("+", "%20"));
Response.BinaryWrite(_Buffer);
Response.Flush(); } }
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货