title: ASP.NET core - middleware on MVC
body: <p>I try to create an asp.net core web api on macOS.</p>
  
  <p>But my middleware isn't called on mvc-call.</p>
  
  <p>My Config: </p>
  
  <pre><code>   public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, BackendDbContext context)
      {
          loggerFactory.AddConsole(Configuration.GetSection("Logging"));
          loggerFactory.AddDebug();
  
          //app.UseStaticFiles();
  
          app.UseMvc();
          app.UseMiddleware&lt;AuthMiddleware&gt;();
  
          BackendDbInitializer.Init(context);
      }
  </code></pre>
  
  <p>And my Middleware: </p>
  
  <pre><code>public class AuthMiddleware 
  {
      private readonly RequestDelegate _next;
  
      public AuthMiddleware(RequestDelegate next)
      {
          _next = next;
      }
  
      public async Task Invoke(HttpContext context)
      {
          Console.WriteLine("Invoke......................");
  
          await _next.Invoke(context);
      }
  }
  </code></pre>
  
  <p>When i do a HTTP-request, that doesn't match a controller request. The middleware class is called.</p>
  
  <p>How can i set up that the middleware class is only called on a mvc-request. </p>