gpt4 book ai didi

c# - ASP.NET 5 (ASP.NET Core) - 无法与 IIS 一起运行

转载 作者:太空狗 更新时间:2023-10-29 23:37:35 25 4
gpt4 key购买 nike

我正在尝试将我的 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()

问题

当我从我的项目开发目录 MySolution\src\MyProject 运行 dnx web 一切正常

我的项目.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. 我使用文件系统选项进行部署,就像在手册中一样
  2. 我安装了 HTTP 平台处理程序
  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 可再发行版

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

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

关于c# - ASP.NET 5 (ASP.NET Core) - 无法与 IIS 一起运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35247869/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com