.NET MVC Core 2 Deployment Issue on IIS 10

2

I am trying to deploy my ASP.NET MVC Core 2 site to a Windows Server 2016 server running IIS 10 and I am getting the following error in the Application Logs.

I have researched the issue and found this .NET Core app unable to start in IIS due to ErrorCode = '0x80004005 : 80008083 question which has an answer that reads, "As VS2017 RC is shipped with the new version of .NET Core SDK (.NET Core 1.0.4 SDK 1.0.1), you need to update framework on server as well."

I have tried installing both the SDK and runtime on the server as advised in the answer above but I am still receiving the error when I navigate to the site.

How can I resolve this issue?

Faulting application name: dotnet.exe, version: 2.0.25816.2, time stamp: 0x59e535ea
Faulting module name: coreclr.dll, version: 4.6.25815.2, time stamp: 0x59e2b767
Exception code: 0xc00000fd
Fault offset: 0x000000000008247a
Faulting process id: 0x1c68
Faulting application start time: 0x01d36aeaea2429cf
Faulting application path: C:\Program Files\dotnet\dotnet.exe
Faulting module path: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.3\coreclr.dll
Report Id: 100b3c83-7509-487e-b1cd-6a0357f8b7e7
Faulting package full name: 
Faulting package-relative application ID: 
asp.net-core
windows-server-2016
iis-10
asked on Stack Overflow Dec 1, 2017 by user1477388 • edited Feb 1, 2018 by Nkosi

1 Answer

1

Running the following command revealed the true error:

C:\Windows\system32>"C:\Program Files\dotnet\dotnet" C:\inetpub\wwwroot\{YOUR_IIS_SITE_NAME}\{YOUR_PROJECT_NAME}.dll

The result in the command prompt was the following which told me I had an error in my connection string:

C:\Windows\system32>"C:\Program Files\dotnet\dotnet" C:\inetpub\wwwroot\www_projectx_com\ProjectX.dll
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
      User profile is available. Using 'C:\Users\darchual\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[58]
      Creating key {70b30c91-49df-45be-95cc-2e681b5cde76} with creation date 2017-12-04 16:34:08Z, activation date 2017-12-04 16:34:08Z, and expiration date 2018-03-04 16:34:08Z.
info: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[39]
      Writing data to file 'C:\Users\darchual\AppData\Local\ASP.NET\DataProtection-Keys\key-70b30c91-49df-45be-95cc-2e681b5cde76.xml'.

Unhandled Exception: System.ArgumentNullException: Value cannot be null.
Parameter name: connectionString
   at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
   at Microsoft.EntityFrameworkCore.SqlServerDbContextOptionsExtensions.UseSqlServer(DbContextOptionsBuilder optionsBuilder, String connectionString, Action`1 sqlServerOptionsAction)
   at ProjectX.Startup.<ConfigureServices>b__4_0(DbContextOptionsBuilder options) in C:\VSO\Avvenire Source\Internal\Project X\ProjectX\Startup.cs:line 35
   ... truncated for brevity ...

Once resolved the application ran perfectly!

Also, keep in mind (when hosting an MVC Core app on IIS) to update your Program.cs file accordingly:

public class Program
{
    public static void Main(string[] args)
    {
        BuildWebHost(args).Run();
    }

    public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseIISIntegration()
            .UseStartup<Startup>()
            .Build();
}

Last, but not least, I needed to fix the connection string by adding a newly created SQL user (it wouldn't work simply using integrated security):

"ConnectionStrings": {
    "DefaultConnection": "Server={theserver};Database={thedatabase};MultipleActiveResultSets=true;User Id={theusername};Password={thepassword};"
},

Ref. https://stackoverflow.com/a/42363471/1477388

answered on Stack Overflow Dec 4, 2017 by user1477388 • edited Dec 4, 2017 by user1477388

User contributions licensed under CC BY-SA 3.0