title: Custom middleware (or authorize) for specific route in ASP .NET Core 3.1 MVC
body: <p>In my ASP .NET Core 3.1 MVC app, I use endpoint routing like so</p>
  
  <pre><code>        app.UseEndpoints(endpoints =&gt;
          {
              endpoints.MapControllerRoute(
                  name: "default",
                  pattern: "{controller=Home}/{action=Index}/{id?}");
  
              endpoints.MapControllerRoute(
                  name: "access",
                  pattern: "access/",
                  defaults: new { controller = "Home", action = "Access" });
          });
  </code></pre>
  
  <p>So browsing to /access, launches the Access action, where the app checks if user complies with some access requirements.</p>
  
  <pre><code>if (access checks...)
  {
      return View();
  }
  </code></pre>
  
  <p>Now I would prefer having this check in a custom middleware (or possibly a custom authorize attribute) instead of having it in the Controller. So my question to you is, how should I rewrite the UseEndPoints call, to include a custom middleware for the /access area?</p>