简体   繁体   English

如何将ASP.NET Core 1.0配置为使用本地IIS而不是IIS Express?

[英]How to configure ASP.NET Core 1.0 to use Local IIS instead of IIS Express?

How can I setup a .Net Core 1.0 project to use Local IIS instead of IIS Express when debugging? 如何在调试时设置.Net Core 1.0项目以使用本地IIS而不是IIS Express

I have tried modifying launchSettings.json file in various ways. 我尝试以各种方式修改launchSettings.json文件。 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. 例如,用本地IIS替换所有出现的IIS Express ,并更新applicationUrllaunchUrl以使用我的自定义本地主机http://sample.local (我已经更新了主机文件并配置了IIS管理器),但并不满意。

Default settings of Properties/launchSettings.json file: Properties / 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"
      }
    }
  }
}

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. 当前,在开发过程中,您不能直接使用IIS来承载ASP.NET Core应用程序,因为开发文件夹无法提供IIS需要承载的所有必需文件。 This makes running an ASP.NET Core in a development environment a bit of a pain. 这使得在开发环境中运行ASP.NET Core有点麻烦。

As pointed out in this article by Rick Strahl , there aren't many reasons to try and do this. 正如Rick Strahl本文中所指出的那样,尝试这样做的理由并不多。 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. 在运行ASP.NET Core应用程序时,IIS几乎没有作用-实际上,您的应用程序不再直接在IIS进程中运行,而是在托管Kestrel Web服务器的完全独立的控制台应用程序中运行。 Therefore you really are running in essentially the same environment when you self host your console application. 因此,当您自行托管控制台应用程序时,您实际上在基本上相同的环境中运行。

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. 如果确实需要发布应用程序,则可以使用dotnet命令行或使用Visual Studio工具将其发布到本地文件夹。

For example, if you want to publish to the C:\\output folder, you can use the following command: 例如,如果要发布到C:\\output文件夹,则可以使用以下命令:

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

You can then point your IIS Site at the output folder. 然后,您可以将IIS站点指向输出文件夹。 Ensure that you set the application pool CLR version to No Managed Code and that the AspNetCoreModule is available. 确保将应用程序池CLR版本设置为“ 无托管代码” ,并且AspNetCoreModule可用。

For more details, see https://docs.asp.net/en/latest/publishing/iis.html 有关更多详细信息,请参见https://docs.asp.net/en/latest/publishing/iis.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM