ziiffi
asked on
C# WebResponse Error 414
My application sends xml file with WebRequest and WebResponse. With GetResponse I ger Exception
System.Net.WebException: The remote server returned an error: (414) Request-URI Too Long
File is 22k and short file works OK.
I know with java following works:
var xmlServerHttp = new ActiveXObject("Msxml2.Serv erXMLHTTP. 3.0");
...
xmlServerHttp.setOption(2, "13056"); // SXH_SERVER_CERT_IGNORE_ALL _SERVER_ER RORS
Has somebody ideas with .NET?
System.Net.WebException: The remote server returned an error: (414) Request-URI Too Long
File is 22k and short file works OK.
I know with java following works:
var xmlServerHttp = new ActiveXObject("Msxml2.Serv
...
xmlServerHttp.setOption(2,
Has somebody ideas with .NET?
It looks like you are trying to send the xml file as part of the URI (GET method). Try using POST method instead, it is only slightly more complicated.
ASKER
This is the exact way I use. Response is needed to check the result.
WebRequest wr;
WebResponse res;
wr = WebRequest.Create(url);
wr.Proxy = GlobalProxySelection.GetEm
wr.Method = "POST";
wr.ContentType = "multipart/form-data";
bytes = System.Text.Encoding.GetEn
wr.ContentLength = bytes.Length;
Stream os = wr.GetRequestStream();
os.Write(bytes, 0, bytes.Length);
os.Close();
res = wr.GetResponse();
Stream rs = res.GetResponseStream();
StreamReader rr = new StreamReader(rs, System.Text.Encoding.GetEn
result = rr.ReadToEnd();
"multipart/form-data" is an encoding type, not a content type. You should use "application/x-www-form-ur lencoded" for the content type.
ASKER
Same error result with this.
Ok, after closer examination, I see the "url" variable, and then you try to send the "url" variable as the content of the POST. Does "url" contain the address or the content to be sent? What is the length in "bytes.Length"?
ASKER
Yes, it contains, and the length of bytes is 22436. This works with shorter messages
This message anf longer works with java and there is used Ignore error option.
This message anf longer works with java and there is used Ignore error option.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
OK. This is the point: separate url and data. Seems much better, Thanks
ASKER
No more errors, I will finalize this tomorrow because remote database is off, However I got remote info message