【发布时间】:2015-10-14 08:57:07
【问题描述】:
我有以下代码让我无法从Request.Params 读取值。现在我只想读取我从发送者传递的值(在接收者中),即用户名和 SAMLResponse。
发件人
protected void Button1_Click(object sender, EventArgs e)
{
HttpWebRequest httpWReq = (HttpWebRequest)WebRequest.Create("MY URL");
httpWReq.Method = "Post";
XElement obj = XElement.Load(@"Load.xml");
StringBuilder postData = new StringBuilder();
postData = postData.Append("username=user&SAMLResponse=").Append(obj.ToString());
byte[] data = Encoding.UTF8.GetBytes(postData.ToString());
httpWReq.Method = "POST";
httpWReq.ContentType = "text/xml;encoding='utf-8'";
httpWReq.ContentLength = data.Length;
using (Stream stream = httpWReq.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
HttpWebResponse response = (HttpWebResponse)httpWReq.GetResponse();
string responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
}
接收者
public ActionResult LoginSSO()
{
string rawSamlData, WindowName;
SSOModel objSSOModel = new SSOModel();
string str = Request.Params["username"];
str = Request.Params["SAMLResponse"];
...
..
}
错误:
任何想法,出了什么问题?
【问题讨论】:
-
string str = Request.Querystring["username"];
标签: c# httpwebrequest saml saml-2.0