c# - How to return response as Content-Type: application/x-www-form-urlencoded; from WCF service? -
after spending insane amount of time make wcf service accept requests content-type: application/x-www-form-urlencoded;
(using stream suggested here best way support "application/x-www-form-urlencoded" post data wcf?)
it works.
however response
content-type: application/xml; charset=utf-8 <string xmlns="http://schemas.microsoft.com/2003/10/serialization/">result</string>
but want
content-type: application/x-www-form-urlencoded; charset=utf-8 result
where can set / hacked?
currently method looks this:
[webinvoke(uritemplate = "generate_license", bodystyle = webmessagebodystyle.bare, method = "post")] [operationcontract] string generatelicense(stream period);
ok, resolved it seems:
public stream generatelicense(stream period) { stream result = new memorystream(); streamwriter sw = new streamwriter(result); sw.write("license"); sw.flush(); result.position = 0; weboperationcontext.current.outgoingresponse.contenttype = "application/x-www-form-urlencoded; charset=utf-8"; return result; }
Comments
Post a Comment