I have a viewstate and eventvalidation token that I am trying to pass in with my app.
The issue I am running into is that I am passing this info in:
string.Format("__EVENTTARGET=&__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE={0}&__EVENTVALIDATION={1}&{2}", viewstate, eventvalidation, request)
eventvalidation has a plus sign in it (+) which is causing a cat of the string, instead of displaying the literal character. Any ideas how I can prevent this from happening?
Here is my code to do the request:
WebRequest req = WebRequest.Create(url);
//Here Request is working properly; the EVENTVALIDATION token has the + sign in it.
byte[] send = Encoding.Default.GetBytes(request);
// I think after I convert it to byte[], it is doing something bad to the EVENTVALIDATION token.
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = send.Length;
Stream sout = req.GetRequestStream();
sout.Write(send, 0, send.Length);
sout.Flush();
sout.Close();
WebResponse res = req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream());
string returnvalue = sr.ReadToEnd();
return returnvalue;
I used Uri.EscapeDataString and this did the trick!