ASP.NET 5(ASP.NET核心) - 无法与IIS一起运行

Ale*_*kov 5 c# asp.net iis asp.net-core

我正在尝试将我的ASP.NET 5 MVC项目部署到本地IIS,但面临一些错误.

错误

当打开(我的网站地址)localhost:80我有HTTP 404.如果我manualy运行,我面临相同的行为approot\web.cmd.我认为问题是一样的.在web.cmd控制台中,我看到每个请求的输出(对于非静态路由,静态文件很好):

fail: Microsoft.Data.Entity.Query.Internal.SqlServerQueryCompilationContextFactory[1]
  An exception occurred in the database while iterating the results of a query.
  System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.SqlClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. File not found.
  File name: 'System.Data.SqlClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.IO.FileNotFoundException: Could not load the specified file.
  File name: 'System.Data.SqlClient'
     at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyName(AssemblyName assemblyName)
     at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
     at Microsoft.Data.Entity.Storage.Internal.SqlServerConnection.CreateDbConnection()
     at Microsoft.Data.Entity.Internal.LazyRef`1.get_Value()
     at Microsoft.Data.Entity.Storage.RelationalConnection.Open()
     at Microsoft.Data.Entity.Query.Internal.QueryingEnumerable.Enumerator.MoveNext()
     at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
     at Microsoft.Data.Entity.Query.Internal.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()
Run Code Online (Sandbox Code Playgroud)

问题

当我dnx web从我的项目开发目录运行MySolution\src\MyProject 它一切都好

我的Project.json

你可以看到我正在使用dnxcore50并且没有依赖System.Data.SqlClient.

{
"userSecretsId": "aspnet5-Stomatology-b7dc4859-6376-4a5f-a583-d17b3660a64c",
"version": "1.0.0-*",
"compilationOptions": {
    "emitEntryPoint": true
},

"dependencies": {
    "AutoMapper": "4.1.1",
    "Domain": "1.0.0-*",
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
    "Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
    "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
    "Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final"
},

"commands": {
    "web": "Microsoft.AspNet.Server.Kestrel",
    "ef": "EntityFramework.Commands"
},

"frameworks": {
"dnxcore50": { }
},

"exclude": [
    "wwwroot",
    "node_modules"
],
"publishExclude": [
    "**.user",
    "**.vspscc"
],
"scripts": {
    "prepublish": [ "npm install", "bower install" ]
}
Run Code Online (Sandbox Code Playgroud)

}

我的部署和IIS设置

  1. 我使用File System选项进行部署,例如manauls
  2. 我安装了HTTP平台处理程序
  3. 我在没有管理环境的情况下使用了Application Pool

结论

那么,有什么方法可以解决这个问题吗?

Ale*_*kov 3

我让它发挥作用了。以下是我为使其正常工作而采取的步骤:

  1. 无法访问所请求的页面,因为该页面的相关配置数据无效。

    • 安装 HTTP 平台处理程序
    • 确保在 Windows 组件中启用 ASP.NET 4.6:Internet 信息服务 -> 全球服务 -> 应用程序开发组件 -> ASP.NET 4.6
  2. 无法加载System.Data.SqlClient

    • 添加System.Data.SqlClient到您的project.json
  3. 无法加载sni.dll

    • 在 x64 操作系统上使用 x64 coreclr 运行时。
    • 安装 MS VC++ 2012 可再发行组件

如果它仍然不起作用... (帮助我今天 08.02.2016 与 1.0.0-rc1-update1): - 删除所有 dnx 运行时 - 在 Visual Studio 中安装 ASP.NET 和 Web 工具的最新更新 -在 VS 的部署设置中设置最新的 x64 运行时

我想,这是某种魔法,我不知道为什么会起作用。