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

查看:20
本文介绍了如何配置 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 中设置网站(右键单击 Sites -> Add Website).

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. 创建一个 ASP .NET 5 Starter App.
  2. 检查它是否在 IIS 之外工作.
  3. 完成后,发布应用程序.在此示例中,我选择了位置 C:PublishWebApp.

3.1.发布您的应用程序时,请确保您拥有:

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

  • 禁用预编译
  • 选择amd64

  • Disabled precompilation
  • Selected amd64

(见下图)

  1. 成功发布后,转到 C:PublishWebApp.您应该会在其中看到文件夹 approotwwwroot.
  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:选择wwwroot文件夹作为网站的物理路径.在此示例中,它是 C:PublishWebAppwwwroot.

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

检查网站以查看其是否正常工作.如果您遇到任何错误,请在此处发布.

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

如果在上图的 Publish Web Settings 窗口中勾选了预编译选项,那么您必须

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

  1. 转到您已发布的 Web 应用程序的 wwwroot 文件夹.在此示例中,它是 C:PublishWebAppwwwroot.
  2. 找到 web.config.
  3. 在您发布的应用程序的文件夹内,approot 文件夹内有一个 packages 文件夹,其中应包含一个以您的应用程序命名的文件夹,并带有一个文件夹下的版本.该文件夹内应该是一个名为 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:PublishWebAppwwwroot.
  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="..approotpackagesWebApplication101.0.0
oot" />

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

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