HttpWebRequest Not Supporting Frames (example included)

  • Thread starter Thread starter Chris Crabtree
  • Start date Start date
C

Chris Crabtree

ok,

So I ran into this problem today with HttpWebRequest and a website
using framesets. I get the response "This page uses frames, but your
browser does not support them."

The only post I can find on the web regarding this issue suggest
setting the UserAgent property to a recognizable browser, so I traced
IE 6 and added the same UserAgent string that it uses. No avail. I
imagine that there must be something wrong with the way I'm doing
this. It appears to be happening with any website I try that uses
frames. Since there is so little mentioned of this problem on the
net, it must be me, I highly doubt I've discovered some big problem.

I've created a very small console app to duplicate the problem. The
code is found below: Please try it yourself and tell me if you can
discover any means to overcome this issue.

Thanks,

Chris
------------------
using System;
using System.IO;
using System.Net;

namespace TestFramesWebRequest
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
Uri uri = new Uri("http://longhorn.msdn.microsoft.com");
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(uri);
req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
..NET CLR 1.1.4322)";

HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Stream s = resp.GetResponseStream();
StreamReader srReadToEnd = new StreamReader(
resp.GetResponseStream() );
Console.WriteLine(srReadToEnd.ReadToEnd());
srReadToEnd.Close();
Console.ReadLine();
}
}
}
 
Chris Crabtree said:
So I ran into this problem today with HttpWebRequest and a website
using framesets. I get the response "This page uses frames, but your
browser does not support them."

That's not because the site actually thinks the browser doesn't support
frames - it's because a user would only see that text if their browser
had ignored the framesets contained within the HTML.

HttpWebRequest doesn't and shouldn't need to have any explicit support
for frames.
 
Chris said:
ok,

So I ran into this problem today with HttpWebRequest and a website
using framesets. I get the response "This page uses frames, but your
browser does not support them."

The only post I can find on the web regarding this issue suggest
setting the UserAgent property to a recognizable browser, so I traced
IE 6 and added the same UserAgent string that it uses. No avail. I
imagine that there must be something wrong with the way I'm doing
this. It appears to be happening with any website I try that uses
frames. Since there is so little mentioned of this problem on the
net, it must be me, I highly doubt I've discovered some big problem.
[...]

It's you ;-)

http://longhorn.msdn.microsoft.com for example returns nested HTML frameset
with the frames "navbar", "panel_header", and "panel". It's up to the client
(your code) to load these individual frames using their "src" attributes.
That's exactly what your browser would do in this case.

Cheers,
 
Back
Top