Domanda

I have problem with configuration for IIS 6.0. I have a server which is used for download purpose, but for all files I would like to add custom header by a module:

private void Application_EndRequest(Object source, EventArgs e)
{
    HttpApplication application = (HttpApplication)source;
    String filePath = application.Request.Path;
    String fileName = VirtualPathUtility.GetFileName(filePath);
    application.Response.AddHeader("Content-Disposition", String.Concat("attachment; filename=\"", fileName, "\""));
}

My problem is that when I try to do that for .exe file it doesn't work. I tried adding under mapping an extension to .exe -> c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll but that only forces to execute the .exe file on server.

I tried also with different execution permissions but setting anything other than Scripts and Executables resturns: HTTP Error 403.1 - Forbidden: Execute access is denied.

Any idea how to force that module to work with .exe files?

È stato utile?

Soluzione

Does it allow you to download .exe file without your module?

  1. On web site properties in IIS manager, Home Directory tab, make sure execute permissions is set to "scripts only".
  2. On web site properties in IIS manager, HTTP Headers tab, be sure to define .exe as a valid MIME type.
  3. Be sure to stop and restart the IIS Service (via Services)

Refer to http://blogs.msdn.com/b/david.wang/archive/2005/07/11/allow-file-downloads-on-iis-6.aspx

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top