6

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

Error

When open (my website address) localhost:80 I've got HTTP 404. I facing the same behaviour if I manualy run the approot\web.cmd. I think the problem is same. In web.cmd console I see this output for every request (for non-static routes, static files works good):

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 run the dnx web from my project development directory MySolution\src\MyProject It's all OK

My Project.json

You can see that I am using dnxcore50 and haven't dependency to 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 deploying and IIS settings

  1. I deploy using File System options, like in manauls
  2. I installed HTTP Platform Handler
  3. I used Application Pool without managment environment

Conclusion

So, is there any way to fix this problem?

3
  • dnx don't copy all the referenced dll's, copy that dll from our framework to the deployed bin folder. Commented Feb 6, 2016 at 23:50
  • @Gusman, I'll try it. But why I need System.Data.Entity if I use EF7, which has no dependencies to System.Data*, but has dependencies to Microsoft.Data.*? Commented Feb 7, 2016 at 8:54
  • P.S. bin you mean myapp\approot\runtimes\myruntime\bin? Commented Feb 7, 2016 at 8:57

1 Answer 1

3

I made it works. Below are the steps I have taken to get it to work:

  1. The requested page cannot be accessed because the related configuration data for the page is invalid.

    • Install HTTP Platform Handler
    • Make sure that ASP.NET 4.6 enabled in Windows Components: Internet Information Servies ->World Wide Services -> Application Development Components -> ASP.NET 4.6
  2. Unable to load System.Data.SqlClient

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

    • Use x64 coreclr runtime on x64 OS.
    • Install MS VC++ 2012 redistributable

If It still doesnt't work... (help for me for present day 08.02.2016 with 1.0.0-rc1-update1): - remove all dnx runtimes - install latest Update for ASP.NET and Web tools in Visual Studio - set the latest x64 runtime in VS in deploy settings

I think, this is a some kind of magic, I don't know, why this works.

Sign up to request clarification or add additional context in comments.

1 Comment

any chance you can replace screenshot with the English one? if not - please remove it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.