Here is the Code:
C#
private string HttpContent( string url )
{
String result="";
try
{
HttpWebResponse objResponse;
HttpWebRequest objRequest = ((HttpWebRequest) (WebRequest.Create(url)));
objRequest.Method ="GET";
objRequest.Timeout = 90000;
objRequest.KeepAlive = false;
objRequest.ProtocolVersion=HttpVersion.Version10;
ServicePointManager.Expect100Continue =false;
objRequest.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040707 Firefox/0.9.2";
//objRequest.Accept = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
//objRequest.ContentType = @"application/x-www-form-urlencoded";
//IWebProxy proxyObject =
//new WebProxy("http://localhost:8099", false);
//objRequest.Proxy=proxyObject;
//objRequest.Proxy=GlobalProxySelection.GetEmptyWebProxy();
//objRequest.Proxy = WebProxy.GetDefaultProxy();
//objRequest.Proxy.Credentials = CredentialCache.DefaultCredentials;
//objRequest.AllowAutoRedirect=true;
//objRequest.MaximumAutomaticRedirections=10;
//objRequest.Timeout=(int) new TimeSpan(0,1,0).TotalMilliseconds;
//objRequest.UserAgent="Mozilla/3.0 (compatible; My Browser/1.0)";
objResponse = ((HttpWebResponse) (objRequest.GetResponse()));
using (StreamReader sr =
new StreamReader(objResponse.GetResponseStream()) )
{
result = sr.ReadToEnd();
result=result.Replace("javascript: window.print()","");
result=result.Replace("../Images/newsletter","http://www.nadp.org/images/newsletter");
// Close and clean up the StreamReader
sr.Close();
}
objResponse.Close();
}
catch(Exception ex)
{
Response.Write(ex.Message.ToString());
}
return result;
}
jaimen2 pointsPosted Apr 4, 2007, 1:26 AM EDT
Check out in your web.config file whether you have any web service which is running on a different sytem and make sure that the system is not shut down. And also ensure that remote service URL of the machine it is pointing to is not shut down.
this should solve your problem...
Bajinder4 pointsPosted Apr 4, 2007, 2:31 AM EDT