title: asp.net core web api work on iis express but not working in iis on windows
body: <p>i am new in asp.net core. i use asp.net core 2.1. i have two controller. a default valuecontroller that doesn't have db connection and customerController that have sqlserver db connection. when i run my project on iis express everything is good but when i publish my project and use windows iis value api work nice but my customer api that have a sqlserver connection doesn't work.</p>
  
  <p>appsettings calss:</p>
  
  <pre><code>{
    "Logging": {
      "LogLevel": {
        "Default": "Warning"
      }
    },
    "AllowedHosts": "*",
    "ConnectionStrings": {
      "DefaultConnection": "Data Source=AHAD;Initial Catalog=mydb;Integrated Security=True"
    }
  }
  </code></pre>
  
  <p>Startup class:</p>
  
  <pre><code>namespace SalesApp
  {
      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().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
              services.AddDbContext&lt;MyDbContext&gt;(Options =&gt;
              {
                  Options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"));
              });
          }
  
          // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
          public void Configure(IApplicationBuilder app, IHostingEnvironment env)
              //,
      //ILoggerFactory loggerFactory,
      //MyDbContext db)
          {
              if (env.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
              }
              else
              {
                  app.UseHsts();
              }
  
              app.UseHttpsRedirection();
              app.UseMvc();
              //loggerFactory.AddConsole(Configuration.GetSection("Logging"));
              //loggerFactory.AddDebug();
  
              //db.Database.Migrate();
  
              //app.UseMvc();
          }
      }
  }
  </code></pre>
  
  <p>MyDbContext class:</p>
  
  <pre><code>public class MyDbContext : DbContext
      {
  
          public MyDbContext()
          {
  
          }
  
          public MyDbContext(DbContextOptions&lt;MyDbContext&gt; options)
              : base(options)
          {
  
          }
  
          //public DbSet&lt;CUSTOMER&gt; customers { get; set; }
  
          public DbSet&lt;CUSTOMER&gt; Customer { get; set; }
  
          protected override void OnModelCreating(ModelBuilder modelBuilder)
          {
              modelBuilder.Entity&lt;CUSTOMER&gt;(entity =&gt;
              {
                  entity.Property(e =&gt; e.C_Code).HasMaxLength(5);
                  entity.Property(e =&gt; e.C_Name).HasMaxLength(60);
                  entity.Property(e =&gt; e.C_Code_C).HasMaxLength(12);
              });
          }
  
      }
  </code></pre>
  
  <p>CustomerController Class:</p>
  
  <pre><code>[Route("api/[controller]")]
      [ApiController]
      public class CustomerController : ControllerBase
      {
          MyDbContext _context;
  
          public CustomerController(MyDbContext context)
          {
              _context = context;
          }
  
          [HttpGet]
          public IActionResult GetCustomers()
          {
              return new ObjectResult(_context.Customer);
          }
  
      }
  </code></pre>
  
  <p>values api:
  <a href="https://i.stack.imgur.com/Xgpzq.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>customer api:
  <a href="https://i.stack.imgur.com/vmwc0.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>it confused me 2 weeks.</p>