I wanted to create a POX endpoint using the ASP.NET MVC 2 controller action. I thought I could reuse a lot of working code and do it in 15 minutes. I was wrong. My actions are as follows:
[HttpPost] [ValidateInput(false)] public ContentResult DoSomething(string xml)
The ValidateInput attribute is required because you will receive an unpleasant validation exception, otherwise when sending the Xml to the action.
Client code:
var req = (HttpWebRequest)WebRequest.Create(endPoint); req.Method = "POST"; req.ContentType = "text/xml"; req.Headers.Add("Accept-Encoding", "gzip,deflate,sdch");
This is working code . The following request is sent to the endpoint (fiddler2)
POST http://doerak/Veekijker/Service.aspx/Melding HTTP/1.1 Content-Type: text/xml Accept-Encoding: gzip,deflate,sdch Host: theHost Content-Length: 2220 Expect: 100-continue Connection: Keep-Alive Xml=theXml
However, when I remove the “Accept-Encoding” header from the client code, the xml line parameter of my controller action is null.
A request without an accept-encoding header is as follows:
POST http://doerak/Veekijker/Service.aspx/Melding HTTP/1.1 Content-Type: text/xml Host: theHost Content-Length: 2220 Expect: 100-continue Xml=theXml
How can I use my controller action without setting the Accept-Encoding header on the client?
source share