0

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?

Gumowy Kaczak
  • 1,457
  • 2
  • 16
  • 28

1 Answers1

1

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

aaron cheung
  • 532
  • 2
  • 10
  • It allows to download .exe file when mapping for .exe to c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll is removed. But when that mapping is removed, it's not being processed by .net so module won't work for .exe. I need some setting allowing me to process .exe file by aspnet_isapi.dll but not trying to run it on server.. only serving it as file. – Gumowy Kaczak Jan 27 '14 at 12:55
  • 1
    In this case you may have to use native [isapi filter](http://msdn.microsoft.com/en-us/library/ms525196%28v=vs.90%29.aspx) to append your headers, as managed http module only applies to managed requests in IIS6. Managed http module starts to work for all request in [IIS7 integrated mode](http://stackoverflow.com/questions/716049/what-is-the-difference-between-classic-and-integrated-pipeline-mode-in-iis7). – aaron cheung Jan 28 '14 at 12:32
  • I was sure that custom ISAPI is a solution, but I had some hope to run it by managed module :) – Gumowy Kaczak Jan 28 '14 at 22:27