【问题标题】:Problems hosting rc1-final-update1 on IIS在 IIS 上托管 rc1-final-update1 的问题
【发布时间】:2016-05-02 00:38:32
【问题描述】:

当我从 Visual Studio(在 IIS express 中)在我的计算机上运行它时,它工作得很好。但是当我尝试在我的服务器(WS 2012,IIS 8)上托管网站时,页面需要永远加载。

我在日志中发现了这个错误:

C:\iis\beta\wwwroot>SET DNX_FOLDER=dnx-clr-win-x86.1.0.0-rc1-update1 

C:\iis\beta\wwwroot>SET "LOCAL_DNX=C:\iis\beta\approot\runtimes\dnx-clr-win-x86.1.0.0-rc1-update1\bin\dnx.exe" 

C:\iis\beta\wwwroot>IF EXIST C:\iis\beta\approot\runtimes\dnx-clr-win-x86.1.0.0-rc1-update1\bin\dnx.exe (SET "DNX_PATH=C:\iis\beta\approot\runtimes\dnx-clr-win-x86.1.0.0-rc1-update1\bin\dnx.exe" ) 

C:\iis\beta\wwwroot>for %a in ((null)) do (IF EXIST %a\runtimes\dnx-clr-win-x86.1.0.0-rc1-update1\bin\dnx.exe (
SET "HOME_DNX=%a\runtimes\dnx-clr-win-x86.1.0.0-rc1-update1\bin\dnx.exe"  
 goto :continue 
) ) 

C:\iis\beta\wwwroot>IF "" NEQ "" (SET "DNX_PATH=" ) 

C:\iis\beta\wwwroot>IF "C:\iis\beta\approot\runtimes\dnx-clr-win-x86.1.0.0-rc1-update1\bin\dnx.exe" == "" (SET "DNX_PATH=dnx.exe" ) 
Error: Unable to load application or execute command 'Microsoft.AspNet.Server.Kestrel'. Available commands: web, ef.
System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
   at System.Reflection.RuntimeAssembly.nLoadFile(String path, Evidence evidence)
   at System.Reflection.Assembly.LoadFile(String path)
   at Microsoft.Dnx.Runtime.Loader.LoadContext.LoadFile(String assemblyPath)
   at Microsoft.Dnx.Runtime.Loader.PackageAssemblyLoader.Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext)
   at Microsoft.Dnx.Runtime.Loader.PackageAssemblyLoader.Load(AssemblyName assemblyName)
   at Microsoft.Dnx.Host.LoaderContainer.Load(AssemblyName assemblyName)
   at Microsoft.Dnx.Host.DefaultLoadContext.LoadAssembly(AssemblyName assemblyName)
   at Microsoft.Dnx.Runtime.Loader.AssemblyLoaderCache.GetOrAdd(AssemblyName name, Func`2 factory)
   at Microsoft.Dnx.Runtime.Loader.LoadContext.LoadAssemblyImpl(AssemblyName assemblyName)
   at Microsoft.Dnx.Runtime.Loader.LoadContext.ResolveAssembly(Object sender, ResolveEventArgs args)
   at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)

这是我的 project.json:

    {
  "webroot": "wwwroot",
  "userSecretsId": "aspnet5-gplayweb-11fc9aea-7741-4cff-ba1f-fc74dfb7600b",
  "version": "1.0.0-*",

  "dependencies": {
    "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.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",
    "Microsoft.AspNet.Session": "1.0.0-rc1-final",
    "MySql.Data": "6.9.8"
  },
  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel",
    "ef": "EntityFramework.Commands"
  },

  "frameworks": {
    "dnx451": { }
  },

  "exclude": [
    "wwwroot",
    "node_modules"
  ],
  "publishExclude": [
    "**.user",
    "**.vspscc"
  ]
}

【问题讨论】:

    标签: asp.net-core iis-8


    【解决方案1】:

    我通过从 approot\src\website\ 中删除 global.json 解决了这个问题。

    【讨论】:

      【解决方案2】:

      F Andrei 的回答为基础。这个sn -p可以放在项目文件中,在每次文件系统发布后删除global.json。

      <Target Name="AfterFileSystemPublish" AfterTargets="FileSystemPublish" Condition="'$(publishUrl)' != ''">
          <!-- 
                remove the src/*/global.json file as it prevents the web site from starting under IIS 
           -->
          <Message Text="Workaround:  Removing $(publishUrl)\approot\src\$(ProjectName)\global.json" Importance="high"/>
          <Exec WorkingDirectory="$(ProjectDir)" Command="del $(publishUrl)\approot\src\$(ProjectName)\global.json"/>
      </Target>
      

      【讨论】:

        【解决方案3】:

        请确保您在服务器上安装了 HttpPlatformHandler。您的应用程序池应配置为无托管代码

        在配置方法的启动文件中,您能否确保您有以下行

        application.UseIISPlatformHandler();

        【讨论】:

        • 一切配置正确。我将尝试在另一台服务器上运行它,以确保它与网站无关。 .
        • 好的,请告诉我进展如何。您是否遵循docs.asp.net/en/latest/publishing/iis.htmldocs.asp.net/en/latest/publishing/iis-with-msdeploy.html 中提到的流程?能否请您发布 web.config 文件的内容?
        • 我遵循了最新指南:docs.asp.net/en/latest/publishing/iis.html。 web.config : pastebin.com/2cfg5nRw
        • 您是否设法将其托管在另一台服务器上?对不起,我一直很忙,没有设法进一步研究这个问题。您的 web.config 看起来不错。只是想知道这是否是运行时间的问题。您是使用 x64 还是 x86 发布?您发布的另一个错误是使用 x86,所以只是想知道您是否在 IIS 上启用了 32 位进程
        • 我在 Visual Studio 中没有 64 位的 dnx clr rc1-final,所以我将它发布为 32 位。我只有 dnx x64 beta 8 。
        【解决方案4】:

        起初问题看起来并不那么明显。我遇到了同样的错误,经过一番努力想出了解决方案。

        1. 像java仓库新的dnx项目结构保持user/xxx/.nuget/packages/ 所有的依赖项,所以如果那里有一个名字来带那个包,dnx会在那里寻找包
        2. 这种情况下,其中一个包已损坏。所以解决方案是 如果您不完全知道发生异常的位置,请删除 .nuget 中的所有包。然后 dnu restore 将再次下载所有软件包。 然后问题就解决了。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多