我正在尝试在Silverlight
中打开一个新窗口。我想通过HTTP Post
请求发送这些参数,而不是使用查询字符串来发送一些参数。我能这样做吗?
谢谢
这就是我的尝试:
private void GoToUrl()
{
System.Net.HttpWebRequest myRequest =
(HttpWebRequest)WebRequest.Create(Url);
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), myRequest);
}
private void GetRequestStreamCallback(IAsyncResult asynchronousResult)
{
HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
System.IO.Stream postStream = request.EndGetRequestStream(asynchronousResult);
string postData = "target=" + EncryptedTarget;
postData += ("&id=" + Id);
byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(postData);
// Write to the request stream.
postStream.Write(byteArray, 0, postData.Length);
postStream.Close();
}
这似乎不再打开我的页面了。我也尝试过使用WebClient,并且也是如此。