0

I am currently trying to deploy my ASP.NET 5 MVC application to a remote server and am having trouble getting it to run correctly with IIS.

My solution DNX SDK version is 1.0.0-beta8-15598.

I have packaged together this project using dnu publish --runtime active and pointed IIS at the wwwroot folder.

My project.json looks like this

{
  "webroot": "wwwroot",
  "version": "1.0.0-*",

  "dependencies": {
    "Microsoft.AspNet.Diagnostics": "1.0.0-beta8-15533",
    "Microsoft.AspNet.Mvc": "6.0.0-beta8-15550",
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta8-15520",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta8-15519",
    "Dapper": "1.42.0",
    "Dapper.SimpleCRUD": "1.8.7",
    "Microsoft.Framework.Logging.Console": "1.0.0-beta8-15514",
    "Microsoft.Framework.Logging.NLog": "1.0.0-beta8-15514",
    "Microsoft.Framework.Configuration.Json": "1.0.0-beta8-15514",
    "Microsoft.AspNet.Cors": "5.1.0-rc1",
    "Dapper.Contrib": "1.43.0",
    "NuGet.CommandLine": "2.8.6"
  },

  "commands": {
    "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://meep:5001"
  },

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

  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ],
  "publishExclude": [
    "node_modules",
    "bower_components",
    "**.xproj",
    "**.user",
    "**.vspscc"
  ],
  "configurations": {
    "Stage": { }
  }
}

The error I get when I attempt to access the remote server in my browser is as follows

[FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)]

[InvalidOperationException: Unable to load application or execute command 'Microsoft.AspNet.Loader.IIS'. Available commands: web.]

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException) +303

[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9931880
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

I am running Windows Server 2012 -- Windows 6.3.9600.

I am unsure how to proceed with solving this as I am unsure of the direct cause of the problem, aside from it not being able to load application or execute command 'Microsoft.AspNet.Loader.IIS'

2 Answers2

0

This worked for me:

  • Ensure you use x64 in your dnu publish command, something like this option --runtime dnx-clr-win-x64.1.0.0-beta8.
  • If you're running Windows Server 2012 with IIS 8, ensure you have the required server roles configured. See Problems publishing asp vnext website on IIS 8.
  • Ensure you use an app pool with settings .NET CLR Version v4.0.x for the .NET CLR version and integrated for the managed pipeline mode.
  • Point your IIS website at the wwwroot folder.

EDIT:

Above description worked for beta7. For beta8 you need Kestrel and the command needs to be called "web". The following project.json works for me to host in IIS, and a 2nd command is optional, but convenient to host it standalone, for example for easy debugging out of visual studio or running service level tests without setting up IIS.

...
"dependencies": {
  "Microsoft.AspNet.Mvc": "6.0.0-beta8",
  "Microsoft.AspNet.Server.Kestrel": "1.0.0-beta8",
  "Microsoft.AspNet.Server.WebListener": "1.0.0-beta8"
},

"commands": {
  "web": "Microsoft.AspNet.Server.Kestrel",
  "web-local": "Microsoft.AspNet.Server.WebListener --server.urls=http://localhost:5000"
},
...
Community
  • 1
  • 1
thoean
  • 1,106
  • 8
  • 15
  • 1
    No luck with that I am afraid. The server roles, app pool and where IIS points are all configured correctly. I attempted dnu publish using an runtime x64 but that didn't appear to make a difference. – MintBerryCrunch Oct 13 '15 at 01:43
0

Now I'm not too sure about this but I know that beta 8 was going to drop IIS Helios support. So I assumed the assembly Microsoft.AspNet.Server.IIS wouldn't be there anymore.

If you take a look at the aspnet templates git hub project the IIS assembly is removed from the project.json and the Microsoft.AspNet.IISPlatformHandler has been added.

To use this you need to call in the startup.cs file. app.UseIISPlatformHandler();

https://github.com/aspnet/Templates/blob/dev/src/BaseTemplates/EmptyWeb/project.json https://github.com/aspnet/Announcements/issues/69

Brandt
  • 341
  • 2
  • 10