Configuring F# CodeDOM provider

Links: Back F# Home F# Library

For F# to work correctly with ASP.NET the CodeDOM provider needs to be configured in the web.config file.

  1. Check that the CodeDom version in the web.config file (e.g. Version=1.9.3.0) matches your installed F# version number.
  2. Add the fsharp binaries directory to your PATH, so CodeDom can find fsc.exe.

Example web.config file:

    <?xml version="1.0"?>
    <configuration>
      <system.web>
        <compilation debug="true">
          <assemblies>
            <add 
              assembly="FSharp.Compiler.CodeDom, Version=1.9.3.0, Culture=neutral,PublicKeyToken=a19089b1c74d0809"/>
          </assemblies>
          <compilers>
            <compiler 
              language="F#;f#;fs;fsharp" extension=".fs" 
              type="Microsoft.FSharp.Compiler.CodeDom.FSharpAspNetCodeProvider"/>
          </compilers>
        </compilation>
      </system.web>
    </configuration>

This should be enough to develop F# ASP.NET using Visual Studio.

Note, for IIS it is necessary to have the ASP.net 2.0 extensions registered (if a website is configured to use ASP.net 2.0 without it being registered you may get 404 errors). If ASP.net 2.0 doesn't appear under "Web Service Extensions" in the IIS control panel, it can be registered using the following command:

  "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -iru -enable

See Installing and Configuring ASP.NET for more information.