Maverick
Maverick

Reputation: 4498

How to configure an MVC6 app to work on IIS?

So I'm building an MVC6 app in Visual Studio 2015 and have managed to figure most stuff out, however, I haven't yet worked out deployment.

In MVC4 (what I was using before), our process* was publish to a folder, then setup the website in IIS (Right-Click on Sites -> Add Website).

I followed this process and obviously it's trivial to setup the IIS website and publish to the correct folder...but that does not actually work for me.

We're running IIS 8 on Windows Server 2012 and we've installed the .Net 4.6 runtime on the server.

Upvotes: 10

Views: 8719

Answers (3)

Mike Hughes
Mike Hughes

Reputation: 77

I have just spent a day trying to get this working. i found this here (search for posts by GuardRex) invaluable, complete the steps the accepted answer gave, that's the start of it.

Pretty much if you try to add an application to a site there is bunch of workarounds and extra configuration needed that is detailed in the link.

For starters:

1)Make sure you have the HttpPlatform handler installed here

2)Seems obvious but make sure .net5 is installed on your server here

I know this is if you are adding an application to a site, but there's some pitfalls and much needed refinements needed for the deployment process at the moment that everyone should be aware of.

Upvotes: 0

Shafqat
Shafqat

Reputation: 1166

I Spent hours on debugging the issue finally got it worked, steps:

1) Publish your MVC6 application using visual studio into file system, make sure you are selecting correct DNX Target version in my case its dnx-clr-win-x64.1.0.0-rc1-update1.

In the output folder map "wwwroot" folder to your applicaiton in IIS (DO NOT Map it to sup-applicaiton, only ROOT application in IIS works with DNX for example "Default Web Site").

Upvotes: 1

dotnetstep
dotnetstep

Reputation: 17485

The following steps have worked for me and should help you host your project on IIS.

Using Visual Studio 2015 Preview as your IDE,

  1. Create an ASP .NET 5 Starter App.
  2. Check that it is working outside of IIS.
  3. Once complete, publish the application. In this example, I have selected the location C:\PublishWebApp.

    3.1. When publishing your application, make sure that you have:

    • Disabled precompilation
    • Selected amd64

      (See image below)

Publish Settings Screenshot

  1. Upon a successful publish, go to C:\PublishWebApp.You should see the folders approot and wwwroot inside.
  2. Now open the IIS Manager (I am assuming you have the ASP .NET 4.5 feature enabled)
  3. Create a new website.

    6.1 : Select the wwwrooot folder as the website's physical path. In this example, it is C:\PublishWebApp\wwwroot.

  4. Check the website to see that it is working. If you encounter any errors, please post them here.

If the precompile option is ticked in the Publish Web Settings window pictured above, then you must

  1. Go to the wwwroot folder of your published web application. In this example, it is C:\PublishWebApp\wwwroot.
  2. Locate web.config.
  3. Inside the folder of your published application, there is an packages folder inside of the approot folder which should contain a folder named after your application, with a folder for the version underneath. Inside that folder should be a folder named root. In web.config, set the value for the key kre-app-base to the root folder. For reference, see the line of code below. In this example, the application name is WebApplication10.

    <add key="kre-app-base" value="..\approot\packages\WebApplication10\1.0.0\root" />
    

Upvotes: 8

Related Questions