3

Works just fine when I run it on my computer from Visual studio ( in IIS express) . But when I try to host the website on my server (WS 2012 , IIS 8 ), the page takes forever to load .

I found this error in log:

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)

Here's my 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"
  ]
}
F Andrei
  • 668
  • 2
  • 9
  • 24

4 Answers4

6

I fixed the problem by deleting global.json from approot\src\website\ .

F Andrei
  • 668
  • 2
  • 9
  • 24
1

Building on answer by F Andrei. This snippet can be placed in the project file to delete the global.json after each file system publish.

<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>
Community
  • 1
  • 1
crokusek
  • 5,345
  • 3
  • 43
  • 61
0

Can you please make sure you have HttpPlatformHandler installed on the server. Your app pool should be configured as No Managed Code

Also in your startup file in Configure method can you please make sure you have the following line

application.UseIISPlatformHandler ();

Shahzad Hassan
  • 993
  • 7
  • 14
  • Everything is configured properly . I will try running it on another server just to be sure it's not related to the website . . – F Andrei Dec 30 '15 at 18:06
  • Ok, please let me know how did it go. Did you follow the process mentioned at https://docs.asp.net/en/latest/publishing/iis.html or at https://docs.asp.net/en/latest/publishing/iis-with-msdeploy.html? Can you please post the contents of web.config file? – Shahzad Hassan Dec 30 '15 at 18:30
  • I followed the latest guide : docs.asp.net/en/latest/publishing/iis.html . web.config : http://pastebin.com/2cfg5nRw – F Andrei Dec 31 '15 at 01:16
  • Did you manage to host it on the other server? Sorry I have been very busy, didn't manage to look further into the problem. Your web.config looks ok. Just wondering if it's an issue with the run time. Are you publishing using x64 or x86? Ther error you have posted is using x86, so just wondering if you have enabled 32 bit process on IIS – Shahzad Hassan Jan 06 '16 at 19:11
  • I don't have dnx clr rc1-final for 64 bit in visual studio, so i published it for 32 bit . I only have dnx x64 beta 8 . – F Andrei Jan 07 '16 at 12:54
  • I tried publishing with dnx 64 bit and it didn't help . Same problem... I will try to run it on another server in a few hours . – F Andrei Jan 07 '16 at 14:37
0

At first the problem doesn't look so obvious. I had the same error and after some effort came up with the solution.

  1. Like java repository new dnx project structure keeps user/xxx/.nuget/packages/ all the dependencies so if a name exist there for bringing that package the dnx looks for the packages in there
  2. This case one of the packages were corrupted. So the solution is delete all the packages inside of .nuget if you don't exactly know from which the exception is occuring. Then dnu restore will download all the packages again. Then the problem is solved.
Moshiour
  • 633
  • 7
  • 20