title: How to send xml through an HTTP request, and receive it using ASP.NET MVC?
body: <p>I am trying to send an xml string through an HTTP request, and receive it on the other end. On the receiving end, I am always getting that the xml is null. Can you tell me why that is?</p>
  
  <p>Send:</p>
  
  <pre><code>    var url = "http://website.com";
      var postData = "&lt;?xml version=\"1.0\" encoding=\"ISO-8859-1\"?&gt;&lt;xml&gt;...&lt;/xml&gt;";
      byte[] bytes = System.Text.Encoding.ASCII.GetBytes(postData);
  
      var req = (HttpWebRequest)WebRequest.Create(url);
  
      req.ContentType = "text/xml";
      req.Method = "POST";
      req.ContentLength = bytes.Length;
  
      using (Stream os = req.GetRequestStream())
      {
          os.Write(bytes, 0, bytes.Length);
      }
  
      string response = "";
  
      using (System.Net.WebResponse resp = req.GetResponse())
      {
          using (StreamReader sr = new StreamReader(resp.GetResponseStream()))
          {
              response = sr.ReadToEnd().Trim();
          }
       }
  </code></pre>
  
  <p>Receive:</p>
  
  <pre><code>[HttpPost]
  [ValidateInput(false)]
  public ActionResult Index(string xml)
  {
      //xml is always null
      ...
      return View(model);
  }
  </code></pre>