Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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).

  • Actually, our process is set it up in IIS and TeamCity, but not for test apps like this :).

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.

like image 813
Maverick Avatar asked Jan 09 '15 03:01

Maverick


People also ask

How do I host a Visual Studio app in IIS?

On the computer where you have the ASP.NET project open in Visual Studio, right-click the project in Solution Explorer, and choose Publish. If you have previously configured any publishing profiles, the Publish pane appears. Click New or Create new profile. Select the option to import a profile.


2 Answers

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" />
    
like image 53
dotnetstep Avatar answered Sep 24 '22 02:09

dotnetstep


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").

like image 44
Xalisys Avatar answered Sep 27 '22 02:09

Xalisys