我们目前在阅读我们过去没有遇到任何问题的ResponseStream时遇到问题.自从昨晚将.NET 4.0 Framwework添加到我们的服务器并分配IIS以使用新框架后,我们在尝试使用以下语句(responseStream = httpResponse.GetResponseStream();)尝试读取responseStream时遇到了一些不同的异常.到目前为止,一切都完美无缺.所以,我正在寻找有关如何从响应中读取的更改/改进.我已经粘贴了我们正在使用的以下代码以及我们遇到的例外情况.
.NET Framework 4.0 Windows Server 2003
HttpWebResponse httpResponse;
Stream responseStream;
//Accept All Certificate Policy
ServicePointManager.ServerCertificateValidationCallback += delegate { return true; };
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(new Uri(theUrl));
httpRequest.Method = "POST";
httpRequest.KeepAlive = false;
httpRequest.Timeout = timeOut;
try
{
httpResponse = (HttpWebResponse)httpRequest.GetResponse();
responseStream = httpResponse.GetResponseStream();
}
Run Code Online (Sandbox Code Playgroud)
'httpResponse.GetResponseStream().Length'抛出类型'System.NotSupportedException'的异常long {System.NotSupportedException}
'httpResponse.GetResponseStream().Position'抛出类型'System.NotSupportedException'的异常long {System.NotSupportedException}
{"此流不支持搜索操作."} System.SystemException {System.NotSupportedException}
问候,
麦克风