I have a controller that looks like to import xml into my site:
[HttpPost] public ActionResult Import(string xml) {
I have a standalone application that reads an XML file and sends it to a URL. It looks like this:
static void Main(string[] args) { var reader = new StreamReader(@"myfile.xml"); var request = WebRequest.Create("http://localhost:41379/mycontroller/import"); request.Method = "POST"; request.ContentType = "text/xml"; StreamWriter sw = new StreamWriter(request.GetRequestStream()); sw.Write(reader.ReadToEnd()); sw.Close(); var theResponse = (HttpWebResponse)request.GetResponse(); StreamReader sr = new StreamReader(theResponse.GetResponseStream()); var response = sr.ReadToEnd(); }
The controller receives the call correctly, but when I enter there, the argument is zero. Iβm sure that Iβm just not asking the right type of content or anything like that. What is the proper way to encode xml so that the structure can receive it and pass it correctly to the rule?
source share