从 ASP.Net 5 'empty' 项目中删除 Kestrel
Removing Kestrel from ASP.Net 5 'empty' project
我在 Visual Studio 2015 年做了一个 'empty' ASP.Net 5 项目。project.json
文件包含这些行
"dependencies": {
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
我正在 Windows 10 开发 PC 上进行测试并计划部署到 Azure,因此,按照 the docs on Servers 中的建议,我想使用 IIS 而不是 Kestrel。
然而,剥离 Kestrel 并不简单。首先,我从 project.json
文件中删除了与 Kestrel 相关的行:
"dependencies": {
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
},
"commands": {
},
构建失败并出现多个错误("The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNet'"、"The type or namespace name 'DependencyInjection' does not exist in the namespace 'Microsoft.Extensions'"、"The type or namespace name 'IServiceCollection' could not be found" 和 "The name 'WebApplication' does not exist in the current context"),因此我添加 dependencies
来修复错误,给出以下内容(成功构建)
"dependencies": {
"EntityFramework.Core": "7.0.0-rc1-final",
"Microsoft.AspNet.Hosting": "1.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-rc1-final"
},
"commands": {
},
但它不会 运行 - 只是无限期挂起,但它还会将行 "web": "Microsoft.AspNet.Server.Kestrel"
添加回 project.json
中的 commands
。
如果我不想,"Hello World" ASP.Net 5 项目中 project.json
文件的 dependencies
和 commands
部分应该是什么样子使用 Kestrel,仅使用 IIS / IIS Express?
following the advise in the docs on Servers, I want to use IIS and not Kestrel.
这个文档有点过时了。您必须使用 Kestrel 或其他支持 asp.net 的 http 侦听器 5. 有关更改 IIS 托管模型的更多信息 here
简而言之:在 IIS 上启动通过 IISPlatformHandler 模块工作,该模块与 Kestrel 等 http 侦听器一起工作。
我在 Visual Studio 2015 年做了一个 'empty' ASP.Net 5 项目。project.json
文件包含这些行
"dependencies": {
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
我正在 Windows 10 开发 PC 上进行测试并计划部署到 Azure,因此,按照 the docs on Servers 中的建议,我想使用 IIS 而不是 Kestrel。
然而,剥离 Kestrel 并不简单。首先,我从 project.json
文件中删除了与 Kestrel 相关的行:
"dependencies": {
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
},
"commands": {
},
构建失败并出现多个错误("The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNet'"、"The type or namespace name 'DependencyInjection' does not exist in the namespace 'Microsoft.Extensions'"、"The type or namespace name 'IServiceCollection' could not be found" 和 "The name 'WebApplication' does not exist in the current context"),因此我添加 dependencies
来修复错误,给出以下内容(成功构建)
"dependencies": {
"EntityFramework.Core": "7.0.0-rc1-final",
"Microsoft.AspNet.Hosting": "1.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-rc1-final"
},
"commands": {
},
但它不会 运行 - 只是无限期挂起,但它还会将行 "web": "Microsoft.AspNet.Server.Kestrel"
添加回 project.json
中的 commands
。
如果我不想,"Hello World" ASP.Net 5 项目中 project.json
文件的 dependencies
和 commands
部分应该是什么样子使用 Kestrel,仅使用 IIS / IIS Express?
following the advise in the docs on Servers, I want to use IIS and not Kestrel.
这个文档有点过时了。您必须使用 Kestrel 或其他支持 asp.net 的 http 侦听器 5. 有关更改 IIS 托管模型的更多信息 here
简而言之:在 IIS 上启动通过 IISPlatformHandler 模块工作,该模块与 Kestrel 等 http 侦听器一起工作。