我有一个视图状态和事件验证令牌,我试图通过我的应用程序传递。
我遇到的问题是我将这些信息传递给:
string.Format("__EVENTTARGET=&__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE={0}&__EVENTVALIDATION={1}&{2}", viewstate, eventvalidation, request)
eventvalidation 中有一个加号 (+),它导致字符串的 cat,而不是显示文字字符。有什么想法可以防止这种情况发生吗?
这是我执行请求的代码:
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;