I have following piece of code which is troubling me to read the value from Request.Params
. Right now I just want to read values (in receiver) that I'm passing from sender i.e. username and SAMLResponse.
Sender
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();
}
Receiver
public ActionResult LoginSSO()
{
string rawSamlData, WindowName;
SSOModel objSSOModel = new SSOModel();
string str = Request.Params["username"];
str = Request.Params["SAMLResponse"];
...
..
}
Error:
Any idea, what is going wrong?