title: Casting between object type of ' FileWebRequest ' to ' HttpRequest '
body: <p>Good evening guys</p>
  
  <p>I'm new here in this forum, and I need you to help me</p>
  
  <p>Am working on a project that send a file of XML, and I'm using HTTPRequest, I faced an error like this:</p>
  
  <blockquote>
    <p>Unable to cast object of type 'System.net.FileWebRequest' to type 'System.net.HTTPWebrequest'</p>
  </blockquote>
  
  <p>![enter image description here][1]</p>
  
  <pre><code>public string POST(string URL, string MsgXML)
  {
    string Response = null;
    try
    {
  
      Request = (HttpWebRequest)HttpWebRequest.Create(URL);
      Request.Method = "POST";
      Request.ContentType = "text/xml";
      byte[] bodyBytes = Encoding.UTF8.GetBytes(MsgXML);
      Request.GetRequestStream().Write(bodyBytes, 0, bodyBytes.Length);
      Request.GetRequestStream().Close();
  
      using (var res = (HttpWebResponse)Request.GetResponse() as HttpWebResponse)
      {
        StreamReader Rdr = new StreamReader(res.GetResponseStream());
        Response = Rdr.ReadToEnd();
        Rdr.Close();
        Rdr = null;
        return Response;
      }
    }
  }
  </code></pre>
  
  <p>And that was the method of posting I used.</p>
  
  <p>And I dnt know what to do, please Help me guys :)</p>