473,513 Members | 3,777 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

An alternative of HttpWebRequest/HttpWebResponse

I used HttpWebRequest/HttpWebResponse to get the content of an URL. It throws
"HTTP Protocol Violation" sometimes. And I set useUnsafeHeaderParsing =
"true" to fix the problem in most case, but for some cases, it does not fix
the problem.

I know there are some problems in server, but I cannot control the server,
and the content shows well in IE. (My content-type is text/plain)

My question is there an alternative way to get content of the URL? I
remember I did something in Perl five years before, Can we use other way in
..NET? I have hoped Microsoft can fix the well-know problem, looks like the
problem remain in framework 2.0

Thanks

Jan 16 '06 #1
4 8879
Qingdong,

It doesn't seem like it is a problem in .NET. From the error, it seems
like the server is returning a response which violates the expected problem.
It is possible that the code is wrong. Can you provide a website where the
classes don't work?

IE is much more tolerant of these things, so it shouldn't be used as a
comparison point. It's expected to be more tolerant.

As for alternatives, you can always use a socket and send the request
yourself, and read/parse the response.

You might try the indy project (http://www.indyproject.org), they
^might^ have something there.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Qingdong Z." <Qi*******@discussions.microsoft.com> wrote in message
news:04**********************************@microsof t.com...
I used HttpWebRequest/HttpWebResponse to get the content of an URL. It
throws
"HTTP Protocol Violation" sometimes. And I set useUnsafeHeaderParsing =
"true" to fix the problem in most case, but for some cases, it does not
fix
the problem.

I know there are some problems in server, but I cannot control the server,
and the content shows well in IE. (My content-type is text/plain)

My question is there an alternative way to get content of the URL? I
remember I did something in Perl five years before, Can we use other way
in
.NET? I have hoped Microsoft can fix the well-know problem, looks like the
problem remain in framework 2.0

Thanks

Jan 16 '06 #2
Nicholas,

I used my local Axis Network Camera.
http://MyIP/axis-cgi/com/ptz.cgi?query=presetposall

But mean while, this works
http://MyIP/axis-cgi/com/ptz.cgi?move=left

Anyways, I still need advice on the alternative method to get content of URL.

Thanks.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Qingdong,

It doesn't seem like it is a problem in .NET. From the error, it seems
like the server is returning a response which violates the expected problem.
It is possible that the code is wrong. Can you provide a website where the
classes don't work?

IE is much more tolerant of these things, so it shouldn't be used as a
comparison point. It's expected to be more tolerant.

As for alternatives, you can always use a socket and send the request
yourself, and read/parse the response.

You might try the indy project (http://www.indyproject.org), they
^might^ have something there.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Qingdong Z." <Qi*******@discussions.microsoft.com> wrote in message
news:04**********************************@microsof t.com...
I used HttpWebRequest/HttpWebResponse to get the content of an URL. It
throws
"HTTP Protocol Violation" sometimes. And I set useUnsafeHeaderParsing =
"true" to fix the problem in most case, but for some cases, it does not
fix
the problem.

I know there are some problems in server, but I cannot control the server,
and the content shows well in IE. (My content-type is text/plain)

My question is there an alternative way to get content of the URL? I
remember I did something in Perl five years before, Can we use other way
in
.NET? I have hoped Microsoft can fix the well-know problem, looks like the
problem remain in framework 2.0

Thanks


Jan 16 '06 #3
Qingdong,

We can't really test that, unfortunately.

The original email has some alternatives you can use.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Qingdong Z." <Qi*******@discussions.microsoft.com> wrote in message
news:9E**********************************@microsof t.com...
Nicholas,

I used my local Axis Network Camera.
http://MyIP/axis-cgi/com/ptz.cgi?query=presetposall

But mean while, this works
http://MyIP/axis-cgi/com/ptz.cgi?move=left

Anyways, I still need advice on the alternative method to get content of
URL.

Thanks.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Qingdong,

It doesn't seem like it is a problem in .NET. From the error, it
seems
like the server is returning a response which violates the expected
problem.
It is possible that the code is wrong. Can you provide a website where
the
classes don't work?

IE is much more tolerant of these things, so it shouldn't be used as
a
comparison point. It's expected to be more tolerant.

As for alternatives, you can always use a socket and send the request
yourself, and read/parse the response.

You might try the indy project (http://www.indyproject.org), they
^might^ have something there.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Qingdong Z." <Qi*******@discussions.microsoft.com> wrote in message
news:04**********************************@microsof t.com...
>I used HttpWebRequest/HttpWebResponse to get the content of an URL. It
>throws
> "HTTP Protocol Violation" sometimes. And I set useUnsafeHeaderParsing =
> "true" to fix the problem in most case, but for some cases, it does not
> fix
> the problem.
>
> I know there are some problems in server, but I cannot control the
> server,
> and the content shows well in IE. (My content-type is text/plain)
>
> My question is there an alternative way to get content of the URL? I
> remember I did something in Perl five years before, Can we use other
> way
> in
> .NET? I have hoped Microsoft can fix the well-know problem, looks like
> the
> problem remain in framework 2.0
>
> Thanks
>


Jan 16 '06 #4
Nicholas,

HTTP Response has some problem definitely. Here is the information I
captured from IE, looks like have problems e.g. --A segment before this
frame was lost---

Here is the all information, I don't know if you can find the problem from
the response. Thanks.
Packetyzer Trace:

Frame 1 (142 bytes on wire, 142 bytes captured)
Frame is marked: False
Arrival Time: Jan 16, 2006 15:04:48.409056000
Time delta from previous packet: -1.079698000 seconds
Time since reference or first frame: 111.041423000 seconds
Frame Number: 1
Packet Length: 142 bytes
Capture Length: 142 bytes
Protocols in frame: eth:ip:tcp:http:data
Ethernet II, Src: 00:40:10:18:b8:28, Dst: 00:0c:f1:bc:5d:08
Destination: 00:0c:f1:bc:5d:08 (Intel_bc:5d:08)
Source: 00:40:10:18:b8:28 (Sonic_18:b8:28)
Source or Destination Address: 00:0c:f1:bc:5d:08 (Intel_bc:5d:08)
Source or Destination Address: 00:40:10:18:b8:28 (Sonic_18:b8:28)
Type: IP (0x0800)
Internet Protocol, Src Addr: 10.10.1.237 (10.10.1.237), Dst Addr:
172.17.0.56 (172.17.0.56)
Version: 4
Header length: 20 bytes
Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00)
0000 00.. = Differentiated Services Codepoint: Default (0x00)
.... ..0. = ECN-Capable Transport (ECT): 0
.... ...0 = ECN-CE: 0
Total Length: 128
Identification: 0xa66f (42607)
Flags: 0x04 (Don't Fragment)
0... = Reserved bit: Not set
.1.. = Don't fragment: Set
..0. = More fragments: Not set
Fragment offset: 0
Time to live: 64
Protocol: TCP (0x06)
Header checksum: 0xdbc8 (correct)
Source: 10.10.1.237 (10.10.1.237)
Source or Destination Address: 10.10.1.237 (10.10.1.237)
Destination: 172.17.0.56 (172.17.0.56)
Source or Destination Address: 172.17.0.56 (172.17.0.56)
Transmission Control Protocol, Src Port: http (80), Dst Port: 2603 (2603),
Seq: 1, Ack: 438, Len: 88
Source port: http (80)
Destination port: 2603 (2603)
Source or Destination Port: 80
Source or Destination Port: 2603
TCP Segment Len: 88
Sequence number: 1 (relative sequence number)
Next sequence number: 89 (relative sequence number)
Acknowledgement number: 438 (relative ack number)
Header length: 20 bytes
Flags: 0x0018 (PSH, ACK)
0... .... = Congestion Window Reduced (CWR): Not set
.0.. .... = ECN-Echo: Not set
..0. .... = Urgent: Not set
...1 .... = Acknowledgment: Set
.... 1... = Push: Set
.... .0.. = Reset: Not set
.... ..0. = Syn: Not set
.... ...0 = Fin: Not set
Window size: 32736
Checksum: 0xec11 (correct)
SEQ/ACK analysis
TCP Analysis Flags
This frame is a (suspected) out-of-order segment
A segment before this frame was lost
Hypertext Transfer Protocol
Data (88 bytes)

0000: 00 0C F1 BC 5D 08 00 40 10 18 B8 28 08 00 45 00 ....]..@...(..E.
0010: 00 80 A6 6F 40 00 40 06 DB C8 0A 0A 01 ED AC 11 ...o@.@.........
0020: 00 38 00 50 0A 2B 88 24 F0 8B 8F 74 E7 52 50 18 .8.P.+.$...t.RP.
0030: 7F E0 EC 11 00 00 50 72 65 73 65 74 20 50 6F 73 ......Preset Pos
0040: 69 74 69 6F 6E 73 20 66 6F 72 20 61 6C 6C 20 63 itions for all c
0050: 61 6D 65 72 61 73 0A 70 72 65 73 65 74 70 6F 73 ameras.presetpos
0060: 6E 6F 31 3D 31 0A 70 72 65 73 65 74 70 6F 73 6E no1=1.presetposn
0070: 6F 32 3D 46 6C 6F 6F 72 0A 70 72 65 73 65 74 70 o2=Floor.presetp
0080: 6F 73 6E 6F 33 3D 43 65 69 6C 69 6E 67 0A osno3=Ceiling.

Jan 16 '06 #5

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

Similar topics

0
3380
by: TJO | last post by:
Can someone at MS please reply to this. I am trying to post data so a web form via ssl with the following code. I keep getting this error: "The underlying connection was closed: Could not establish secure channel for SSL/TLS" private void mainHttpCalls(string postData) { HttpWebRequest objRequest1 ; HttpWebRequest objRequest2 ;
2
11533
by: Kueishiong Tu | last post by:
I have a url, I pass it to Webclient, and I get response without any problem. String* uriString = S"trade7.masterlink.com.tw/futures/QuotePrice.jsp"; String* postData = S""; // Create a new WebClient instance. WebClient* myWebClient = new WebClient(); // Apply ASCII Encoding to obtain the String* as a Byte array. Byte postArray=...
9
8152
by: Mike Cronin via DotNetMonster.com | last post by:
Hi there, Can anyone tell me what level of encryption is used when making an HTTPS POST request through an instance of the System.Net.HttpWebRequest object? Thanks much in advance! Mike Cronin Data On Call - Programmer
2
6796
by: TK | last post by:
I have a trouble to get web resopnse from an aspx page which is secured by Forms Authentication with custom user account database. My client application is a console application but not a browser. I want to download a file from my webapplication. I've learned that the NetworkCredential class gives a way to go but no luck. My code is as...
15
6376
by: Snedker | last post by:
I'm using (HttpWebRequest and HttpWebResponse to check for updates. But how do I determine the size of the file before download? What I have in mind is a status text like "You have downloaded xxxx of yyyy bytes" I'm trying to find the y's within this: ---
5
35257
by: rlueneberg | last post by:
I am totally confused. Can someone please illuminate what is going on under the hood in this piece of code from John Lewis. My main confusion is how the cookieContainer can be passed to the subsequent request if it is not assigned anywhere? So far this is what I understand: -Creates New cookieContainer CookieContainer cookieContainer...
12
7935
by: Mark Rae | last post by:
Hi, The following code works: HttpWebRequest objRequest = null; try { HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create("http://www.microsoft.com"); using (HttpWebResponse objResponse =
1
5637
by: ALA | last post by:
Hi, does anybody know if it is possible to pass the SessionID with a web request by using a cookie so that the invoked page in the same domain can access the session objects of the current user? HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.CookieContainer = new CookieContainer(); HttpCookie sessionCookie =...
15
3077
by: Nightcrawler | last post by:
I am currently using the HttpWebRequest and HttpWebResponse to pull webpages down from a few urls. string url = "some url"; HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url); using (HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse()) {
0
7270
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7178
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7397
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7563
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5102
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4757
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3252
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
1612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.