title: Asp.net Core 2 - Static files not working on prod but they work through iis express
body: <p>When  running my asp.net core 2  app (web api) locally on iis express, calling static resources seem to work, but when deployed to iis 8 i get a 404 trying to access.
  Here is my setup, locally i put the resource in wwwroot while startup.cs, program.cs are one directory higher.</p>
  
  <p>when deployed, all the compiled/published dlls and the resource are deployed to the wwwroot of website.  Now my apis work fine onlie, for example i have a route defined such as </p>
  
  <pre><code> [HttpGet]
   [Route("api/misc/categories")]
   public IActionResult Categories()
   {
       return Ok(DbContext.Categories);
   }
  </code></pre>
  
  <p>so calling <a href="http://cryptocal.imetasoft.com/api/misc/categories" rel="nofollow noreferrer">http://cryptocal.imetasoft.com/api/misc/categories</a> returns the categories as it should but <a href="http://cryptocal.imetasoft.com/index.html" rel="nofollow noreferrer">http://cryptocal.imetasoft.com/index.html</a> returns a 404, even though the index.html and cryptocal.dll are both in the wwwroot on my webserver (prod)</p>
  
  <p>I believe I have everything setup properly.
  I added a nuget package to <code>Microsoft.AspNetCore.StaticFiles v2.0</code></p>
  
  <p><strong>.csproj content</strong></p>
  
  <pre><code> &lt;Project Sdk="Microsoft.NET.Sdk.Web"&gt;
  
    &lt;PropertyGroup Label="Globals"&gt;
      &lt;SccProjectName&gt;SAK&lt;/SccProjectName&gt;
      &lt;SccProvider&gt;SAK&lt;/SccProvider&gt;
      &lt;SccAuxPath&gt;SAK&lt;/SccAuxPath&gt;
      &lt;SccLocalPath&gt;SAK&lt;/SccLocalPath&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;PropertyGroup&gt;
      &lt;TargetFramework&gt;netcoreapp2.0&lt;/TargetFramework&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;Folder Include="wwwroot\" /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.0" /&gt;
      &lt;PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" /&gt;
      &lt;PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" /&gt;
      &lt;PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" /&gt;
      &lt;PackageReference Include="morelinq" Version="2.7.0" /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" /&gt;
    &lt;/ItemGroup&gt;
  
  &lt;/Project&gt;
  </code></pre>
  
  <p><strong>Program.cs</strong> No changes (defaults from generated template)</p>
  
  <p>using Microsoft.AspNetCore;
  using Microsoft.AspNetCore.Hosting;</p>
  
  <pre><code>namespace CryptoCal
  {
      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><strong>Startup.cs</strong></p>
  
  <pre><code>using Microsoft.AspNetCore.Builder;
  using Microsoft.AspNetCore.Hosting;
  using Microsoft.Extensions.Configuration;
  using Microsoft.Extensions.DependencyInjection;
  using CryptoCal.Models;
  using Microsoft.EntityFrameworkCore;
  using CryptoCal.Support;
  
  namespace CryptoCal
  {
      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.AddDbContext&lt;CryptoDateContext&gt;(options =&gt; options.UseSqlServer(Configuration.GetConnectionString("CryptoCalDatabase")));
              services.Configure&lt;GeneralSettings&gt;(Configuration.GetSection("GeneralSettings"));
              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.UseDefaultFiles();
              app.UseStaticFiles();
              app.UseMvc(x =&gt;
              {
  
              });
          }
      }
  }
  </code></pre>