ASP.NET 5(ASP.NET核心) - 无法与IIS

时间:2016-02-06 23:35:33

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

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

错误

打开时(我的网站地址)localhost:80我有HTTP 404.如果我手动运行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()

问题

当我从项目开发目录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" ]
}

}

我的部署和IIS设置

  1. 我使用File System选项进行部署,例如manauls
  2. 我安装了HTTP平台处理程序
  3. 我使用了没有管理环境的应用程序池
  4. 结论

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

1 个答案:

答案 0 :(得分:2)

我做到了。以下是我采取的步骤:

  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 OS上使用x64 coreclr运行时。
    • 安装MS VC ++ 2012可再发行组件
  4. 如果它仍然不起作用... (帮助我今天08.02.2016与1.0.0-rc1-update1):   - 删除所有dnx运行时   - 在Visual Studio中安装ASP.NET和Web工具的最新更新   - 在部署设置中设置VS中的最新x64运行时

    我认为,这是一种魔力,我不知道,为什么会这样。