如何配置MVC6应用程序在IIS上工作? [英] How to configure an MVC6 app to work on IIS?

查看:211
本文介绍了如何配置MVC6应用程序在IIS上工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在Visual Studio 2015中构建了一个MVC6应用程序并设法解决了大部分内容,但是,我还没有完成部署。

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.

在MVC4(我之前使用的)中,我们的进程*被发布到一个文件夹,然后在IIS中设置网站(右键单击站点 - > 添加网站)。

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


  • 实际上,我们的流程是在IIS和TeamCity中设置的,但不是对于这样的测试应用程序:)。

我遵循了这个过程,显然设置IIS网站并发布到正确的文件夹是微不足道的...但这对我来说实际上并不起作用。

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.

我们在Windows Server 2012上运行IIS 8,我们在服务器上安装了.Net 4.6运行时。

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

推荐答案

以下步骤对我有用,应该可以帮助您在IIS上托管项目。

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

使用Visual Studio 2015 Preview作为IDE,

Using Visual Studio 2015 Preview as your IDE,


  1. 创建AS P .NET 5 Starter App。

  2. 检查它是否在IIS之外工作。

  3. 完成后,发布应用程序。在此示例中,我选择了位置 C:\ PububinWebApp

3.1。发布应用程序时,请确保您具有:

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


  • 已禁用预编译

  • 已选择amd64

  • Disabled precompilation
  • Selected amd64

(见下图)


  1. 成功发布后,转到 C:\ PububinWebApp .You应该看到文件夹 approot wwwroot 里面。

  2. 现在打开IIS经理(我假设你启用了ASP .NET 4.5功能)

  3. 创建一个新网站。

  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 :选择 wwwrooot 文件夹作为网站的物理路径。在此示例中,它是 C:\ PububinWebApp \ www.root

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

检查网站看到它正在发挥作用。如果您遇到任何错误,请在此处发布。

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. 转到你发布的网站的 wwwroot 文件夹应用。在此示例中,它是 C:\ PububinWebApp \ www.root

  2. 找到 web.config

  3. 在已发布应用程序的文件夹中,内部有一个 packages 文件夹。 approot 文件夹,其中应包含一个以应用程序命名的文件夹,下面是该版本的文件夹。在该文件夹中应该是名为 root 的文件夹。在 web.config 中,将键 kre-app-base 的值设置为 root 文件夹。供参考,请参阅下面的代码行。在此示例中,应用程序名称为WebApplication10。

  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" />


这篇关于如何配置MVC6应用程序在IIS上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆