ASP.NET 5 (ASP.NET core) - cannot work with IIS

I am trying to deploy my ASP.NET 5 MVC project to a local IIS, but encountering some errors.

Error

When open (my website address) localhost:80 I have HTTP 404. I encounter the same behavior if I manually run approot\web.cmd . I think the problem is the same. In the web.cmd console web.cmd I see this output for each request (for non-static routes, static files work well):

 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() 

Problem

When I start dnx web from the project development directory MySolution\src\MyProject Everything is OK

My project.json

You can see that I am using dnxcore50 and have no dependency on 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" ] } 

}

My Deployment and IIS Settings

  • I use File System options, for example, in manuals
  • I installed the HTTP platform handler
  • I used an application pool without a management environment

Conclusion

So, is there a way to fix this problem?

+5
source share
1 answer

I have done it. Following are the steps I took to get it working:

  • The requested page is not available because the configuration data associated with it is invalid for the page.

    • Install the HTTP platform handler
    • Ensure that ASP.NET 4.6 is enabled in the Windows components: Internet Information Servies β†’ World Wide Services β†’ Application Development Components β†’ ASP.NET 4.6
  • Unable to load System.Data.SqlClient

    • Add System.Data.SqlClient to project.json
  • Unable to load sni.dll

    • Use x64 coreclr runtime for x64 OS.
    • Install Redistributable MS VC ++ 2012

If it still does not work ... (help me today 02/08/2016 with 1.0.0-rc1-update1): - remove all dnx time intervals - install the latest update for ASP.NET and web tools in Visual Studio - install the latest x64 in VS in deployment settings

I think this is some kind of magic, I don’t know why it works.

+2
source

Source: https://habr.com/ru/post/1242459/


All Articles