Download office document without the web server trying to render it

Posted by Dan Revell on Stack Overflow See other posts from Stack Overflow or by Dan Revell
Published on 2010-04-01T15:22:37Z Indexed on 2010/04/01 15:23 UTC
Read the original article Hit count: 255

I'm trying to download an InfoPath template that's hosted on SharePoint. If I hit the url in internet explorer it asks me where to save it and I get the correct file on my disk. If I try to do this programmatically with WebClient or HttpWebRequest then I get HTML back instead.

How can I make my request so that the web server returns the actual xsn file and doesn't try to render it in html. If internet explorer can do this then it's logical to think that I can too.

I've tried setting the Accept property of the request to application/x-microsoft-InfoPathFormTemplate but that hasn't helped. It was a shot in the dark.

© Stack Overflow or respective owner

Related posts about c#

Related posts about httpwebrequest