title: Exclude route from middleware - .net core
body: <p>I have 2 middlewares in the application. I want to exclude one route from those middlewares. What i have tried is creating a BuildRouter functions and apply middlewares through it but this didn't work.</p>
  
  <pre><code>public IRouter BuildRouter(IApplicationBuilder applicationBuilder)
  {
      var builder = new RouteBuilder(applicationBuilder);
  
      builder.MapMiddlewareRoute("/api/", appBuilder =&gt; {
          appBuilder.ApplyKeyValidation();
          appBuilder.ApplyPolicyValidation();
      });
  
      return builder.Build();
  }
  </code></pre>
  
  <p>And the configure method is</p>
  
  <pre><code>public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  {
      if (env.IsDevelopment())
      {
          app.UseDeveloperExceptionPage();
      }
      else
      {
          app.UseHsts();
      }
  
      app.UseRouter(BuildRouter(app));
  
      app.UseHttpsRedirection();
      app.UseMvc();       
  }
  </code></pre>
  
  <p>But this is not working.</p>