Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C# WebResponse Error 414

Posted on 2008-06-09
9
Medium Priority
?
2,294 Views
Last Modified: 2010-04-21
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.ServerXMLHTTP.3.0");
...
 xmlServerHttp.setOption(2, "13056"); // SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS

Has somebody ideas with .NET?

0
Comment
Question by:ziiffi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 18

Expert Comment

by:ChetOS82
ID: 21745798
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.
0
 

Author Comment

by:ziiffi
ID: 21748697

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.GetEmptyWebProxy();
wr.Method = "POST";
wr.ContentType = "multipart/form-data";

bytes = System.Text.Encoding.GetEncoding("iso-8859-1") .GetBytes (url);
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.GetEncoding("iso-8859-1"));
result = rr.ReadToEnd();
0
 
LVL 18

Expert Comment

by:ChetOS82
ID: 21750379
"multipart/form-data" is an encoding type, not a content type.  You should use "application/x-www-form-urlencoded" for the content type.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ziiffi
ID: 21753440
Same error result with this.
0
 
LVL 18

Expert Comment

by:ChetOS82
ID: 21753469
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"?
0
 

Author Comment

by:ziiffi
ID: 21754032
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.
0
 
LVL 18

Accepted Solution

by:
ChetOS82 earned 1000 total points
ID: 21754126
Ok, well you cannot have a URI that is that long.  That isn't how POST method works anyway.  You need to set the URL to just the URL, and have another variable which contains the actual data.  If you prefix the data with something like "data=", then you can retrieve the form data using Request.Form("data").
0
 

Author Comment

by:ziiffi
ID: 21754809
OK. This is the point: separate url and data. Seems much better, Thanks
0
 

Author Closing Comment

by:ziiffi
ID: 31465507
No more errors, I will finalize this tomorrow because remote database is off, However I got remote info message
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question