Width property is lost when using the GetResponseStream() function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm using the next code to get the source code from a web page and save it to
disk, all works fine except that the width property is lost:

wrRequest = (HttpWebRequest)HttpWebRequest.Create("www.server.com/page.aspx");
wrResponse = (HttpWebResponse)wrRequest.GetResponse();
srReader = new StreamReader(wrResponse.GetResponseStream());
sHTML = srReader.ReadToEnd();

why this error if when I see the web page from the server it works ok?

in the source code from IE directly from the page of the web server, the
input tag is as follow:

<input name="NAME" type="text" value="VALUE" id="IDNAME" disabled="disabled"
style="width:368px;" />

but in the source code from the page saved in local disk the input tag is:

<input name="NAME" type="text" value="VALUE" id="IDNAME" disabled="disabled"
/>

the style="width:368px;" property doesn't apear, any help?
 
Andres Romero said:
I'm using the next code to get the source code from a web page and save it
to
disk, all works fine except that the width property is lost:

wrRequest =
(HttpWebRequest)HttpWebRequest.Create("www.server.com/page.aspx");
wrResponse = (HttpWebResponse)wrRequest.GetResponse();
srReader = new StreamReader(wrResponse.GetResponseStream());
sHTML = srReader.ReadToEnd();

why this error if when I see the web page from the server it works ok?

in the source code from IE directly from the page of the web server, the
input tag is as follow:

<input name="NAME" type="text" value="VALUE" id="IDNAME"
disabled="disabled"
style="width:368px;" />

but in the source code from the page saved in local disk the input tag is:

<input name="NAME" type="text" value="VALUE" id="IDNAME"
disabled="disabled"
/>

the style="width:368px;" property doesn't apear, any help?

The web server is probably sniffing your "browser" and sending you downlevel
HTML.

Try adding

request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
..NET CLR 1.1.4322)"

David
 
David Browne said:
The web server is probably sniffing your "browser" and sending you downlevel
HTML.

Try adding

request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
..NET CLR 1.1.4322)"

David
 
Back
Top