Webclient.Download using .config file type generates 403 error

G

Guest

I am using Webclient.download to HTTP download a file from an IIS 6.0 server.
It works for all the files I have except for those type .config.
If I rename the files to .txt extension, it works.
I've added MIME types to support .config files as application/xml but I
still get the 403 error.
Is there a way other than renaming the file extension?
 
M

Marc Gravell

This is due to the handler in web.config.

By default, .config gets a HttpForbiddenHandler (except for
..exe.config and .dll.config which get StaticFileHandler - at least on
my setup).

I strongly suggest that you leave this alone; otherwise it allows
people to snoop at your configuration, which is not great, even if it
is encrypted (which many aren't).

If the file is actually the config for an app, either use the above (I
can't remember if this is default or custom), or use the ClickOnce
trick and add .deploy to the name, i.e. myapp.exe.deploy,
myapp.exe.config.deploy - and strip it again after download.

If the config in question is in a sub-folder, you could add a
web.config, remove the existing .config handler and add a new one.
Standard web.config stuff. Let me know if you don't know how.

Marc
 
G

Guest

Marc,

Thanks, I was afraid of that. I was considering renaming the file and
download it but thought maybe there is a better way.. other than ClickOnce.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top