I have small application in C# 4.0. Remote server is Apache2.
I have problem with error: The remote server returned an error: (414) Request-URI Too Large when I send here data using POST method.
I try use this code to connect to apache2:
String mainAddressWebApi = "http://myremoteserver.domain.pl/alias/index.php";
private HttpWebRequest request;
request = (HttpWebRequest)WebRequest.Create(this.mainAddressWebApi);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.Referer = "http://stackoverflow.com";
request.UserAgent = "Mozilla/5.0";
request.CookieContainer = cookie;
NetworkCredential credentials = new NetworkCredential("login", "password");
this.request.Credentials = credentials;
Byte[] byteData = utf8.GetBytes(data);
request.ContentLength = byteData.Length;
Stream newstream = request.GetRequestStream();
newstream.Write(byteData, 0, byteData.Length);
newstream.Close();
this.response = (HttpWebResponse)request.GetResponse(); //I get error here
Data should send using POST. Data have max to 2mb. Can you help me?