如何配置ASP.NET Core 1.0以使用本地IIS而不是IIS Express? [英] How to configure ASP.NET Core 1.0 to use Local IIS instead of IIS Express?

查看:1159
本文介绍了如何配置ASP.NET Core 1.0以使用本地IIS而不是IIS Express?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在调试时设置 .Net Core 1.0 项目以使用本地IIS 而不是 IIS Express

How can I setup a .Net Core 1.0 project to use Local IIS instead of IIS Express when debugging?

我尝试过以各种方式修改 launchSettings.json 文件。例如,将所有出现的 IIS Express 替换为本地IIS 并更新 applicationUrl launchUrl 以使用我的自定义localhost http://sample.local (我已更新主机文件并已配置IIS管理器)但不满意。

I have tried modifying launchSettings.json file in various ways. For example, replacing all occurrences of IIS Express with Local IIS and updating the applicationUrl and launchUrl to use my custom localhost http://sample.local (I have updated the host file and configured IIS manager already) but not happy.

属性/ launchSettings.json 文件的默认设置:

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:38601/",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "SampleApp": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}


推荐答案

您目前无法直接使用IIS来托管ASP.NET Core appli开发时阳离子,因为开发文件夹不提供IIS需要托管的所有必要文件。这使得在开发环境中运行ASP.NET Core有点痛苦。

You currently cannot directly use IIS to host an ASP.NET Core application while developing, as the development folder does not provide all of the necessary files IIS needs to host. This makes running an ASP.NET Core in a development environment a bit of a pain.

正如 Rick Strahl的这篇文章,没有太多理由尝试这样做。运行ASP.NET核心应用程序时IIS几乎没有 - 实际上您的应用程序不再直接在IIS进程中运行,而是在托管Kestrel Web服务器的完全独立的控制台应用程序中运行。因此,当您自行托管您的控制台应用程序时,您确实在基本相同的环境中运行。

As pointed out in this article by Rick Strahl, there aren't many reasons to try and do this. IIS does very little when running ASP.NET Core apps - in fact your application no longer runs directly in the IIS process, instead it runs in a completely separate console application hosting the Kestrel web server. Therefore you really are running in essentially the same environment when you self host your console application.

如果需要发布您的应用程序,可以使用 dotnet 命令行或使用Visual Studio工具对本地文件夹执行此操作。

If you do need to publish your app, you can do so to a local folder, using either the dotnet command line, or using the Visual Studio tools.

例如,如果要发布到 C:\ output 文件夹,可以使用以下命令:

For example, if you want to publish to the C:\output folder, you can use the following command:

dotnet publish
  --framework netcoreapp1.0 
  --output "c:\temp\AlbumViewerWeb" 
  --configuration Release

然后,您可以将IIS站点指向输出文件夹。确保将应用程序池CLR版本设置为 No Managed Code 并且 AspNetCoreModule 可用。

You can then point your IIS Site at the output folder. Ensure that you set the application pool CLR version to No Managed Code and that the AspNetCoreModule is available.

有关详细信息,请参阅 https://docs.asp.net/en/latest/publishing/iis.html

For more details, see https://docs.asp.net/en/latest/publishing/iis.html

这篇关于如何配置ASP.NET Core 1.0以使用本地IIS而不是IIS Express?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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