title: .NET Core - 404 error on server only
body: <p>I have a very simple .NET Core test application that runs on my development machine but causes a 404 when run on my server under IIS 10.  Initially, the goal was to return a few database records in JSON, like a web service. However, to narrow the field of search for the error, I have changed the application to return a single, constant string. The result is the same -- works on the dev machine and fails on the server.</p>
  
  <p>On the dev machine, I ran it from Visual Studio 15.5.7. I published to the server using Web Deploy.</p>
  
  <p>Based on other posts, I also tried setting "No Managed Code" for the IIS App Pool, but it made no difference.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Threading.Tasks;
  using Microsoft.AspNetCore.Mvc;
  using Newtonsoft.Json;
  namespace api.iVoterGuide.com.Controllers
  {
      [Route("api/ballot")]
      public class BallotController: Controller {
          // GET api/value  --  ballot/542
          [HttpGet("{eleck}")]
          public IEnumerable&lt;string&gt; Get(short elecK)
          {
              yield return "[ 1, 2, 3]";
          }
      }
  }
  </code></pre>
  
  <p>Here is Startup.cs</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Threading.Tasks;
  using Microsoft.AspNetCore.Builder;
  using Microsoft.AspNetCore.Hosting;
  using Microsoft.Extensions.Configuration;
  using Microsoft.Extensions.DependencyInjection;
  using Microsoft.Extensions.Logging;
  using Microsoft.Extensions.Options;
  
  namespace api.iVoterGuide.com
  {
      public class Startup
      {
          public Startup(IConfiguration configuration)
          {
              Configuration = configuration;
          }
  
          public IConfiguration Configuration { get; }
  
          // This method gets called by the runtime. Use this method to add services to the container.
          public void ConfigureServices(IServiceCollection services)
          {
              services.AddMvc();
          }
  
          // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
          public void Configure(IApplicationBuilder app, IHostingEnvironment env)
          {
              if (env.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
              }
              app.UseMvc();
          }
      }
  }
  </code></pre>
  
  <p>Program.cs</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.IO;
  using System.Linq;
  using System.Threading.Tasks;
  using Microsoft.AspNetCore;
  using Microsoft.AspNetCore.Hosting;
  using Microsoft.Extensions.Configuration;
  using Microsoft.Extensions.Logging;
  
  namespace api.iVoterGuide.com
  {
      public class Program
      {
          public static void Main(string[] args)
          {
              BuildWebHost(args).Run();
          }
  
          public static IWebHost BuildWebHost(string[] args) =&gt;
              WebHost.CreateDefaultBuilder(args)
                  .UseStartup&lt;Startup&gt;()
                  .Build();
      }
  }
  </code></pre>
  
  <p>web.config</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
       &lt;!-- It works either with or without this CORS code --&gt;
       &lt;system.webServer&gt;
            &lt;handlers accessPolicy="Read, Execute, Script" /&gt;
            &lt;httpProtocol&gt;
                 &lt;customHeaders&gt;
                      &lt;add name="Access-Control-Allow-Origin" value="*" /&gt;
                 &lt;/customHeaders&gt;
            &lt;/httpProtocol&gt;
        &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Release.pubxml (EDITED)</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;!--
  This file is used by the publish/package process of your Web project. You can customize the behavior of this process
  by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121. 
  --&gt;
  &lt;Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
    &lt;PropertyGroup&gt;
      &lt;WebPublishMethod&gt;FileSystem&lt;/WebPublishMethod&gt;
      &lt;PublishProvider&gt;FileSystem&lt;/PublishProvider&gt;
      &lt;LastUsedBuildConfiguration&gt;Release&lt;/LastUsedBuildConfiguration&gt;
      &lt;LastUsedPlatform&gt;Any CPU&lt;/LastUsedPlatform&gt;
      &lt;SiteUrlToLaunchAfterPublish /&gt;
      &lt;LaunchSiteAfterPublish&gt;True&lt;/LaunchSiteAfterPublish&gt;
      &lt;ExcludeApp_Data&gt;False&lt;/ExcludeApp_Data&gt;
      &lt;ProjectGuid&gt;e86ba648-3c13-472c-b91c-1d0925762870&lt;/ProjectGuid&gt;
      &lt;publishUrl&gt;bin\Release\PublishOutput&lt;/publishUrl&gt;
      &lt;DeleteExistingFiles&gt;True&lt;/DeleteExistingFiles&gt;
      &lt;TargetFramework&gt;netcoreapp2.0&lt;/TargetFramework&gt;
    &lt;/PropertyGroup&gt;
  &lt;/Project&gt;
  </code></pre>
  
  <p>launchSettings.json</p>
  
  <pre><code>{
    "iisSettings": {
      "windowsAuthentication": false,
      "anonymousAuthentication": true,
      "iisExpress": {
        "applicationUrl": "http://localhost:57342/",
        "sslPort": 0
      }
    },
    "profiles": {
      "IIS Express": {
        "commandName": "IISExpress",
        "launchBrowser": true,
        "launchUrl": "api/values",
        "environmentVariables": {
          "ASPNETCORE_ENVIRONMENT": "Development"
        }
      },
      "api.iVoterGuide.com": {
        "commandName": "Project",
        "launchBrowser": true,
        "launchUrl": "api/values",
        "environmentVariables": {
          "ASPNETCORE_ENVIRONMENT": "Development"
        },
        "applicationUrl": "http://localhost:57343/"
      }
    }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/zPt0P.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zPt0P.png" alt="enter image description here"></a></p>
  
  <p>Does anyone have any suggestions? Thanks in advance.</p>
  
  <p>EDIT: Following the advice from another article (which I can no longer find) I tried running my app from the command line. </p>
  
  <pre><code>D:\wwwroot\api.iVoterGuide.com&gt;dotnet .\api.ivoterguide.com.dll
  Error: An assembly specified in the application dependencies manifest (api.ivoterguide.com.deps.json) was not found:
  package: 'Microsoft.ApplicationInsights.AspNetCore', version: '2.1.1'
  path: 'lib/netstandard1.6/Microsoft.ApplicationInsights.AspNetCore.dll'
  This assembly was expected to be in the local runtime store as the application was published using the following target manifest files:
  aspnetcore-store-2.0.0-linux-x64.xml;aspnetcore-store-2.0.0-osx-x64.xml;aspnetcore-store-2.0.0-win7-x64.xml;aspnetcore-store-2.0.0-win7-x86.xml
  </code></pre>
  
  <p>Here is the --info result on the server:</p>
  
  <pre><code>D:\wwwroot\api.iVoterGuide.com&gt;dotnet --info
  Microsoft .NET Core Shared Framework Host
  
  Version  : 2.0.6
  Build    : 74b1c703813c8910df5b96f304b0f2b78cdf194d
  </code></pre>
  
  <p>Even with this information I have not been able to solve the problem. I have tried installing the newest .NET version, changing the .NET Core version in my csproj (), and several other small changes suggested by other articles.</p>
  
  <p>I still cannot get to run.  Any suggestions.</p>