Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HttpWebResponse problem

Status
Not open for further replies.

cyrus71

Programmer
Feb 6, 2006
34
SE
Hi,

I have tryed to load my rss feeds from a given URL by using following code in my web part. But the problem is when the URL does not exists i get web part Error something like "WebPart1 has occured a error .. if you have permission troubleshoot.....


HttpWebRequest HWReq = (HttpWebRequest)WebRequest.Create(URL);

// I have to use following row if i want to know if HWReq.HaveResponse is false or true, and it is the problem itself, I get the error when it call GetResponse(), so i have to have some contorl before following row. but what control?

HttpWebResponse HWResp = (HttpWebResponse)HWRequest.GetResponse();
 
why don't you surround your code in a try { } catch { } statement?

try
{
// whatever code throws an error
}
catch(Exception)
{

}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top