Skip to main content

'webRequest.GetRequestStream()' threw an exception of type 'System.Net.ProtocolViolationException'

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [.NET Compact Framework Development] >> .NET Compact Framework forum for C# >> 'webRequest.GetRequestStream()' threw an exception of type 'System.Net.ProtocolViolationException' Page: [1]
Login
Message << Older Topic   Newer Topic >>
'webRequest.GetRequestStream()' threw an exception of t... - 11/3/2009 3:47:23 AM   
funnypeck

 

Posts: 2
Score: 0
Joined: 11/3/2009
Status: offline
i'm new in mobile development, i already find many related post for many days, hope experts in forum can help me find the solution, thank you.

the code is work fine in desktop application but when move to compact framework, some error found,one of the error show below:

below is my code

HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Method = "POST";
webRequest.Timeout = this.TimeOutMiliSecs;
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.KeepAlive = false;

Byte[] bytes = Encoding.GetEncoding("UTF-8").GetBytes(this.Param);
Stream os = null;
WebResponse webResponse = null;
HttpWebResponse response = null;
StreamReader sr = null;
String errorMsg = "-999-" + System.Environment.NewLine;

try
{
webRequest.ContentLength = bytes.Length;
//i get the error 'System.Net.ProtocolViolationException' in this line
os = webRequest.GetRequestStream();
os.Write(bytes, 0, bytes.Length);
webResponse = webRequest.GetResponse();
sr = new StreamReader(webResponse.GetResponseStream(), System.Text.Encoding.GetEncoding("UTF-8"));
this.Value = sr.ReadToEnd().Trim();
}

hope can get the solution soon

< Message edited by funnypeck -- 11/3/2009 3:48:39 AM >
Post #: 1
RE: 'webRequest.GetRequestStream()' threw an exception ... - 11/13/2009 3:19:33 AM   
funnypeck

 

Posts: 2
Score: 0
Joined: 11/3/2009
Status: offline
after i do more testing, i found that the symbol come out after i select "upgrade project" i think HttpWebRequest not support for all platform.

after i downgrade to 2.0, the problem above is missing but i get another error, i found that StringSplitOptions is not supported in compact framework 2.0, have anyone can point me a correct direction how to fix this error, thank you

(in reply to funnypeck)
Post #: 2
Page:   [1]
All Forums >> [.NET Compact Framework Development] >> .NET Compact Framework forum for C# >> 'webRequest.GetRequestStream()' threw an exception of type 'System.Net.ProtocolViolationException' Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.5.5 Unicode

0.016