【问题标题】:ASP.NET 5 application not working with IIS: Unable to load application or execute command 'Microsoft.AspNet.Loader.IIS'ASP.NET 5 应用程序无法与 IIS 一起使用:无法加载应用程序或执行命令“Microsoft.AspNet.Loader.IIS”
【发布时间】:2015-10-12 01:25:21
【问题描述】:

我目前正在尝试将我的 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'

【问题讨论】:

    标签: c# asp.net .net asp.net-mvc iis


    【解决方案1】:

    现在我对此不太确定,但我知道 beta 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

    【讨论】:

      【解决方案2】:

      这对我有用:

      • 确保在 dnu publish 命令中使用 x64,类似于此选项 --runtime dnx-clr-win-x64.1.0.0-beta8
      • 如果您正在运行带有 IIS 8 的 Windows Server 2012,请确保您已配置所需的服务器角色。见Problems publishing asp vnext website on IIS 8
      • 确保您使用的应用程序池设置为 .NET CLR Version v4.0.x 用于 .NET CLR 版本,integrated 用于托管管道模式。
      • 将您的 IIS 网站指向 wwwroot 文件夹。

      编辑:

      以上描述适用于 beta7。对于 beta8,您需要 Kestrel,并且该命令需要称为“web”。以下 project.json 适用于我在 IIS 中托管,第二个命令是可选的,但方便独立托管,例如便于在 Visual Studio 之外进行调试或在不设置 IIS 的情况下运行服务级别测试。

      ...
      "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"
      },
      ...
      

      【讨论】:

      • 恐怕不走运。服务器角色、应用程序池和 IIS 点均已正确配置。我尝试使用运行时 x64 进行 dnu 发布,但这似乎没有什么不同。
      猜你喜欢
      • 2016-02-18
      • 1970-01-01
      • 2016-03-31
      • 1970-01-01
      • 1970-01-01
      • 2016-02-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多