471,337 Members | 841 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

HttpWebResponse status 404, when page has frame

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
Nov 29 '05 #1
0 1428

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Nuno Magalhaes | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.