Provides X-Sendfile functionality for IIS7.x
C#
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
XSendfile
LICENSE
README.textile
XSendfile.dll
XSendfile.pdb

README.textile

X-Sendfile and X-Accel-Redirect Support for IIS 7.x

This module provides basic support for X-Sendfile and X-Accel-Redirect headers.

As per Oct 7 2016, also X-Sendfile-Temporary is supported. When using this header, the file to be sent to the client is considered to be a temporary file and will be deleted from disc afterwards. In case you write software that can not know whether the installation supports this version of the module or the previous one without X-Sendfile-Temporary support, it can use both headers. The old version of the module will then pick up the X-sendfile header and the current version will pick up the X-Sendfile-Temporary method, so this provides a fallback mechanism.

Note that X-Sendfile-Temporary keeps the thread running until the result is fully streamed to the client. On intensive use, this can lead to thread shortages. When the CLR thread pool becomes exhausted, requests will start to queue, causing a hang.

Usage

Either compile again for the target .net environment or use the supplied .net 4 dll
For more details on what the below settings mean and do, please consult Apache or NGinx documentation

Install the DLL

  • Copy the assembly compiled to the /BIN directory located in the root of your application.
    • If this directory does not exist, create it.
  • Configure the module and handler to be loaded in the application.
    • Open the IIS7 Administration tool
    • double-click on your server node in the left-hand tree view, then expand the “Sites” node, and click on the site or application to which you would like to add your module and handler.
      • Select the “Modules” feature icon, then click the “Add Managed Module…” action, and in the resulting dialog box type in the module name (arbitrary) and the fully-qualified module type “XSendfile.XSendfileHttpModule”.
      • Press OK to add the module.

Select one of the optional configurations below:

Config the base directory if using X-Sendfile (optional)

  1. Open the IIS manager
  2. Select your web application
  3. Double click application settings
    • Click add…
    • name: XSendDir
    • value (for example): c:\inetpub\private

Config location if using X-Accel-Redirect (optional)

  1. Open the IIS manager
  2. Select your web application
  3. Double click application settings
    • Click add…
      • name: XAccelLocation
      • value (for example): /virtual/path
    • Click add…
      • name: XAccelRoot
      • value (for example): c:/base/dir

Common Settings

  • XSendCache: [NoCache|Private|Public] (defaults to NoCache)
  • XSendMime: False (defaults to null)
    • If this setting is not set then the mime type will be set using your IIS site mime settings
    • Setting this to false means the Content-Type header needs to be set by your application

Ensure IIS has access

  • Make sure the directory exists
  • You can run the following command to provide the IIS User read/write access
    • icacls c:\inetpub\private /grant BUILTIN\IIS_IUSRS:RW