473,396 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Problem with HttpWebRequest to read a web page

Good Morning,
I need to read a web page, to do this I use the following code that
works well if I choose

sAddressTime = "http://www.etantonio.it/it/index.aspx"

and you can see the trace results at
http://www.etantonio.it/it/trad_OK.aspx

while it is not working if I choose

sAddressTime =
"http://babelfish.altavista.com/babelfish/trurl_pagecontent?url=http%3a%2f%2fwww.etantonio.i t%2fIT%2fUniversita%2fMasterSatellitare%2findex.as px&lp=IT_EN";
and in this case you can see the trace results at
http://www.etantonio.it/it/trad_NOT_OK.aspx

the page I ask for could be regularly seen with a web browser at this
address :
http://babelfish.altavista.com/babel....aspx&lp=IT_EN
but when I ask to open it with my script this is the error reported :
System.Net.WebException: The underlying connection was closed: The
server committed an HTTP protocol violation.
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncRes ult asyncResult)
at System.Net.HttpWebRequest.GetResponse()
at ASP.Trad_NOT_OK_aspx.Page_Load(Object Src, EventArgs E) in
D:\Inetpub\webs\etantonioit\it\trad_NOT_OK.aspx:li ne 15
here it is the simple code and I hope you can help me to solve the
error:

************************************************** **************************
<%@ Page Language="c#" Trace="true" Debug="true" %>
<%@ import Namespace="System.Net" %>
<%@ import Namespace="System.IO" %>
<script runat="server">
void Page_Load(Object Src, EventArgs E )
{
if (!Page.IsPostBack)
{
String sAddressTime =
""http://babelfish.altavista.com/babelfish/trurl_pagecontent?url=http%3a%2f%2fwww.etantonio.i t%2fIT%2fUniversita%2fMasterSatellitare%2findex.as px&lp=IT_EN";
// String sAddressTime = "http://www.etantonio.it/it/index.aspx";

Trace.Write("sAddressTime",sAddressTime);
try
{
HttpWebRequest req =
(HttpWebRequest)WebRequest.Create(sAddressTime);
HttpWebResponse result = (HttpWebResponse)req.GetResponse();
Stream ReceiveStream = result.GetResponseStream();
StreamReader reader = new StreamReader(ReceiveStream,
Encoding.ASCII);
String respHTML = reader.ReadToEnd();
Trace.Write("respHTML",respHTML);
}
catch (Exception e)
{
Trace.Write("EX" , e.ToString());
}
}
}
</script>
<html><head><title>Etantonio</title></head><body ></body></html>
************************************************** **************************

many thanks for your help,

Antonio D'Ottavio
www.etantonio.it/en/

Nov 17 '05 #1
4 3019
The error raised from that server is this :

The underlying connection was closed: The server committed an HTTP
protocol violation.
Status: ServerProtocolViolation

how I can bypass it ?? Can you help me ??
Many thanks

Antonio D'Ottavio
www.etantonio.it/en/

Nov 17 '05 #2
et*******@gmail.com wrote:
The error raised from that server is this :

The underlying connection was closed: The server committed an HTTP
protocol violation.
Status: ServerProtocolViolation

how I can bypass it ?? Can you help me ??


..NET 2.0 is bit more specific regarding that error:

System.Net.WebException: The server committed a protocol violation.
Section=ResponseHeader Detail=CR must be followed by LF

That *is* a protocol violation :-/

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 17 '05 #3
So this is the true error but how I can resolve this ??
The strange is that there is no error if I open with Internet explorer
this page :

http://babelfish.altavista.com/babel....aspx&lp=IT_EN

while if I read the page with my script at the link :

http://www.etantonio.it/it/trad_NOT_OK.aspx

I have the protocol violation. There is a way to not consider this
protocol violation ??

Many thanks

Antonio D'Ottavio
www.etantonio.it/en/

Nov 17 '05 #4
et*******@gmail.com wrote:
So this is the true error but how I can resolve this ??
The strange is that there is no error if I open with Internet explorer
this page :

http://babelfish.altavista.com/babel...nt?url=http%3a
%2f%2fwww.etantonio.it%2fIT%2fUniversita%2fMasterS atellitare%2findex.a
spx&lp=IT_EN
Well, IE does use a different HTTP implementation which is more lenient
;-)

while if I read the page with my script at the link :

http://www.etantonio.it/it/trad_NOT_OK.aspx

I have the protocol violation. There is a way to not consider this
protocol violation ??


I'm afraid not -- unless you roll your own HTTP stack or use P/Invoke
to call WinHTTP.

One thing to consider: This problem may also cause any infrastructure
component in between to fail...

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Helen Abell | last post by:
Hi, I am trying to use a .Net WebClient object to read data from a url, but I am getting the following error: System.Net.HttpWebRequest.CheckFinalStatus()...
1
by: Bruce Wiebe | last post by:
hi all Im having a big problem connecting to a SSL site (HSBC Bank) using httpWebRequest. what i need to do is connet to the site and pass over an xml string and read the response. Im pretty...
1
by: etantonio | last post by:
Good Morning, I need to read a web page, to do this I use the following code that works well if I choose sAddressTime = "http://www.etantonio.it/it/index.aspx" and you can see the trace...
1
by: sfoxover | last post by:
Hi, Could someone please give me some suggestions on how to make this class robust. I need to be able to handle around 20 similtanious requests to this class which causes a web browser to...
1
by: Dave Brown | last post by:
I am attempting to post to a url (https://FakeURL/logon.asp) using the HttpWebRequest class. The response for a succesful post will contain the html for the logon user's default page. We've...
8
by: Dave Brown | last post by:
I am attempting to post to a url (https://FakeURL/logon.asp) using the HttpWebRequest class. The response for a succesful post will contain the html for the logon user's default page. We've...
10
by: Danny | last post by:
I am working on a project where I will receive xml documents from clients machines as a byte array. They will use the web browser navigate method to post the data to my ASP.NET page. I then pick up...
0
by: Alex Papadimoulis | last post by:
Hey Group, I'm in the process of converting an ASP-based site to an ASP.NET site and built a control that wraps around an ASP page. The control simply does a GET to the same server to render the...
0
by: Alex Papadimoulis | last post by:
Hey Group, I'm in the process of converting an ASP-based site to an ASP.NET site and built a control that wraps around an ASP page. The control simply does a GET to the same server to render the...
0
by: davidpenty | last post by:
Hi there, I am having some problems with a multi-threaded asp.net seach page. My search page sends off four asynchronous http requests to four search engines then waits for the results to come...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.