Problem:
I am writting a quick and dirty web link checker for a site that allows
local business to post their web site's URL. I have encountered a probelm
when the reqested URI points to a site that contains a frame loading content
from another domain. Any insight would be welcome.
The Web Page:
I try to hit a url (see code below) say http://www.somedomain.com, works
fine from IE, but HttpWebResponse gives 404
the web site source appears in IE as :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>home.net</title>
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
</head>
<frameset border=0 rows="100%,*" noresize>
<frame marginwidth=0 marginheight=0 frameborder=0 framespacing=0
name="TOPFRAME"
src="http://www.somenewdomain.com/?dn=home.net&cid=domai43992/fxallen/golfpage.htm"
noresize>
</frameset>
</html>
The Code:
private bool CheckLink( string url, WebProxy proxy )
{
bool failed = false;
HttpWebRequest request = null;
HttpWebResponse response = null;
request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Timeout = 8000;
request.Proxy = proxy;
request.AllowAutoRedirect = true;
try
{
response = (HttpWebResponse)request.GetResponse();
}
catch( WebException wex)
{
HandleWebException( wex );
failed = true;
}
catch( Exception ex )
{
HandleUnexpectedException( ex );
}
finally
{
if( response != null )
{
response.Close();
response = null;
}
}
return failed;
}
Cheers,
Howeird