I am uploading an xml and the posting it on my action method.At the top of the received file there is information ------WebKitFormBoundarytuARn4Bf71AoeFqG Content-Disposition: form-data; name="file"; filename="samplexmp.xml" Content-Type: text/xml because of which I cannot load it on XDocument.This is my code
public ActionResult PostXml()
{
string xml = "";
if (Request.InputStream != null)
{
StreamReader stream = new StreamReader(Request.InputStream);
string x = stream.ReadToEnd();
xml = HttpUtility.UrlDecode(x);
var xmldocument = XDocument.Parse(xml);//Exception (Invalid data at the root)
}
return View();
}
This is my view
@using (Html.BeginForm("PostXml", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
input type="file" name="file"
input type="submit" value="Upload"
}
How can I remove that additional data?