tags:

views:

220

answers:

1

Hello! I have a problem downloading particular file types by WebClient. So there are no problems with usual types - mp3, doc and others, but when I rename file extension to config it returns me: InnerException = {System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)

when I'm trying to access this file in browser (http://localhost:3182/Silverlight.config) - it's a usual xml file within - server returns me following error page:

Server Error in '/' Application.

This type of page is not served. Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.config' may be incorrect. Please review the URL below and make sure that it is spelled correctly.

Requested URL: /Silverlight.config

So I suppose this hapens because of some server configuration, which blocks files of unknown type.

downloading code is simple:

WebClient webClient = new WebClient();
webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(webClient_OpenReadCompleted);                
webClient.OpenReadAsync(new Uri("../Silverlight.config", UriKind.RelativeOrAbsolute));

completted eventhandler omitted for simplicity.

+1  A: 

I'm not sure this is possible.

The .config extension is handled by the ASP.NET engine, for security reasons (sensitive data like connection strings need to be kept safe and hidden from unauthorized viewers).

This means that visitors cannot view your web.config file's content by simply entering "www.example.com/web.config" into their browser's adress bar.

EDIT : actually you can but I don't recommand it. If you really need to do it, you have to remove the mapping between the .config extension and ASP.NET ISAPI filter in IIS.

Olivier PAYEN
Yes, You're right - it is a kind of reserved one - file with cfg extension is downloaded ok!
Andrey Khataev