question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MapFallback catch all requests to API controller when ConsumeAttribute added

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Hello. In .net 6 behavior of MapFallback broke when ConsumesAttribute was added. MapFallback catch all requests to API controller. In .net 6 index.html file always returns on requests to API controller but if I remove endpoints.MapFallbackToFile or delete ConsumesAttribute filter then everything works as I expected. In .net 5 the example works correctly.

ConsumesAttribute was added for the correct generation of swagger.json by Swashbuckle in order not to add it to every action or controller.

Expected Behavior

Requests to controllers must not be catched by MapFallback.

Steps To Reproduce

    public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers(options => options.Filters.Add(new ConsumesAttribute("application/json")));
        }
        public void Configure(IApplicationBuilder app)
        {
            app.UseRouting();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                endpoints.MapFallbackToFile("index.html");
            });
        }
    }

Exceptions (if any)

No response

.NET Version

6.0.200

Anything else?

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:14 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
msftbot[bot]commented, Jun 1, 2022

Thanks for contacting us. We’re moving this issue to the .NET 7 Planning milestone for future evaluation / consideration. Because it’s not immediately obvious that this is a bug in our framework, we would like to keep this around to collect more feedback, which can later help us determine the impact of it. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it’s very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

1reaction
javiercncommented, Oct 3, 2022

@davidfowl absolutely.

@MackinnonBuck can you take care of it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to map fallback in ASP .NET Core Web API so that ...
Now I want to change it so that the Blazor WASM app only responds to requests from https://localhost:44331 and not requests to https://localhost ......
Read more >
FallbackEndpointRouteBuilderEx...
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will match requests for non-file-names with the lowest possible priority.
Read more >
ASP.NET Core Web API - How to Handle GET Request
Every web API controller class inherits from the ControllerBase abstract class that provides all the necessary behavior for the derived class.
Read more >
Building a URL Shortener Web App using Minimal APIs in . ...
This API has to cover lots of input variations, thus the easiest way to catch all URLs is to use the MapFallback() method....
Read more >
Post in ASP.NET Core REST API
In this video we will discuss, how to create a new item, i.e implement http post in ASP.NET Core REST API. To create...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found