I have a sharepoint webpart that makes an httpwebrequest to an ASP.NET web page. The webpage polls a database and spits out an rss feed as xml. Whenever I try to get the response from the page I am getting an IO exception : "Unable to read data from the transport connection: The connection was closed." As of right now I am not trying to do anything complicated with the stream just read it and write the text to a label in a panel on the webpart. Here is the code
request = (HttpWebRequest)WebRequest.Create
("http://xxhrnsp-asm/_layouts/1033/custom/RetrieveRSS.aspx" +
sourceStr + startDateStr + endDateStr);
// set the method
request.Method = "GET";
// use current users credentials
request.Credentials = CredentialCache.DefaultCredentials;
// set keep alive (may not be needed)
request.KeepAlive = false;
// set the timeout REALLY high. (if it takes this long might as well not use it)
request.ReadWriteTimeout = request.Timeout = 60000;
// get the response
response = (HttpWebResponse)request.GetResponse();
if (response != null)
{
StreamReader rssReader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
String rssString = rssReader.ReadToEnd();
// do something with the response
ResultsPanel.Controls.Remove(ResultsLabel);
ResultsPanel.Height = 720;
ResultsLabel.Text = rssString;
ResultsPanel.Controls.Add(ResultsLabel);
// cleanup
rssReader.Close();
response.Close();
}
The aspx page itself works fine. I can go to a browser and type in the URL and an RSS feed based on the parameters pops up. The line that reads String rssString = rssReader.ReadToEnd(); is the one that is causing the errors.