Posts
1150
Comments
891
Trackbacks
1
Deploying an Asp.Net 5 MVC 6 RC 1 WebApi to IIS

I’d worked through some of the issues with WebApi 2 before, so it was largely the same, with a couple of differences due to the half-baked implementations.  I certainly hope it gets better.

You need to do these things:

  1. Install the Http Platform Handler

    You will need to go here and download the relevant 1.2 or higher handler.  Out of curiosity, does anyone run 32-bit anymore?  I installed the 64 bit one.

  2. Update your web.config

    Even when you get other things set up, you may find that you can’t PUT or DELETE.  On the web you will see things about doing things with WebDav and other stuff, but you need to update the web.config in the wwwroot to handle this properly.  Yes, apparently, web.config still does things, even if it ignores connection strings and app settings.  Here’s mine:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <modules runAllManagedModulesForAllRequests="true">
          <remove name="WebDAVModule"/>
        </modules>
        <httpProtocol>
          <customHeaders>
            <add name="Access-Control-Allow-Origin" value="*" />
            <add name="Access-Control-Allow-Headers" value="Content-Type" />
            <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
          </customHeaders>
        </httpProtocol>
        <handlers>
          <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
          <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
          <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
          <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
          <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
          <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
          <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
        </handlers>
        <httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" startupTimeLimit="3600"/>
      </system.webServer>
    </configuration>

  3. Create an unmanaged code application pool

    You should know how to do this.  Create a new app pool, but tell it ‘no managed code’ since the new framework handles all that.

  4. File publish your application

    Pick a location, and file publish your app there.  I certainly hope that publishing to a web site will be implemented again, since if you have to set up a remote server, you have to file publish locally, and then copy it.  Oh, and you may need to turn off your site when publishing after the site set up, since it isn’t currently smart enough to handle existing file locks like the previous web publishing worked in Visual Studio.

    This is where Microsoft just keeps screwing up the basic.  Hanselman thinks it’s cool to move code from a PC to a MAC, since it’s way RAD KEWL and all that.  As if anyone is going to be developing .NET for OSX (I mean, odd developers like me might, but not web sites.  There are no OSX servers (none that matter).  But that ginormous group of existing folk that want to publish a site to IIS?  Is that a priority?  Nah.  But I digress .

  5. Wire it up

    Create your site in IIS.  Point it to the wwwroot folder where you published it (if you needed to copy it, you should copy over approot and wwwroot even though you point to wwwroot.  I don’t know why, I’m sure David Fowler can explain it).  Use the application pool you created.

    You should be good to go.
posted on Sunday, December 27, 2015 11:22 PM Print
Comments
No comments posted yet.

Post Comment

Title *
Name *
Email
Url
Comment *  
Please add 3 and 7 and type the answer here: