Alex Rivera | Logout

How to set WebClient Content-Type Header?

Asked 2009-10-20T16:54:22.087
29

To conect to a third party service I need to make a Https Post. One of the requisites set is to sent a custom content type.

I'm using WebClient, but I can't find how to set it. I've tried making a new class and overriding the CreateRequest Method, but that make request crash.

Is there any way to do that without having to rewrite CopyHeadersTo method?

EDIT CopyHeaderTo is a method I've seen using .NET Reflector. It's invoked from GetWebRequest and sets all Request Headers, including Content-Type, from private properties.

Edit
Report

1 Answer

4

Well, I just missed Request.ContentType property. If GetWebRequest method is overridden, setting ContentType to whatever value desired does it.

Still, connection to third party is not working. Go figure.

answered 2009-10-21T08:19:13.703

Your Answer