我目前正在尝试将我的ASP.NET 5 MVC应用程序部署到远程服务器,并且无法使其与IIS正确运行。
我的解决方案DNX SDK版本是1.0.0-beta8-15598。
我使用dnu publish --runtime active
将此项目打包在一起,并将IIS指向wwwroot文件夹。
我的project.json看起来像这样
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Diagnostics": "1.0.0-beta8-15533",
"Microsoft.AspNet.Mvc": "6.0.0-beta8-15550",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta8-15520",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta8-15519",
"Dapper": "1.42.0",
"Dapper.SimpleCRUD": "1.8.7",
"Microsoft.Framework.Logging.Console": "1.0.0-beta8-15514",
"Microsoft.Framework.Logging.NLog": "1.0.0-beta8-15514",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta8-15514",
"Microsoft.AspNet.Cors": "5.1.0-rc1",
"Dapper.Contrib": "1.43.0",
"NuGet.CommandLine": "2.8.6"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://meep:5001"
},
"frameworks": {
"dnx451": { }
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
],
"configurations": {
"Stage": { }
}
}
我尝试在浏览器中访问远程服务器时收到的错误如下
[FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)]
[InvalidOperationException: Unable to load application or execute command 'Microsoft.AspNet.Loader.IIS'. Available commands: web.]
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException) +303
[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9931880
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
我正在运行Windows Server 2012 - Windows 6.3.9600。
我不确定如何解决这个问题,因为我不确定问题的直接原因,除了它无法load application or execute command 'Microsoft.AspNet.Loader.IIS'
答案 0 :(得分:0)
这对我有用:
dnu publish
命令中使用x64,类似于此选项--runtime dnx-clr-win-x64.1.0.0-beta8
。.NET CLR Version v4.0.x
的应用程序池,为托管管道模式使用integrated
。编辑:
以上描述适用于beta7。对于beta8,你需要Kestrel,命令需要被称为“web”。以下project.json适用于我在IIS中托管,第二个命令是可选的,但可以方便地独立托管它,例如,可以在不设置IIS的情况下轻松调试Visual Studio或运行服务级别测试。
...
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-beta8",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-beta8",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta8"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
"web-local": "Microsoft.AspNet.Server.WebListener --server.urls=http://localhost:5000"
},
...
答案 1 :(得分:0)
现在我对此不太确定,但我知道测试版8会降低IIS Helios支持。所以我假设程序集Microsoft.AspNet.Server.IIS将不再存在。
如果您查看aspnet模板git hub项目,则会从project.json中删除IIS程序集,并添加了Microsoft.AspNet.IISPlatformHandler。
要使用此功能,您需要调用startup.cs文件。 app.UseIISPlatformHandler();
https://github.com/aspnet/Templates/blob/dev/src/BaseTemplates/EmptyWeb/project.json https://github.com/aspnet/Announcements/issues/69