I'm practicing middlewares in ASP.NET Core 5. So I created a new web API project and removed all files except Startup.cs and Program.cs. I also removed all the service registration in ConfigureServices
and removed all the middlewares in the Configure
method.
I have added a simple inline Run
middleware in the Configure
method as shown below.
app.Run(async (context) =>
{
await context.Response.WriteAsync("Hello from Run Middleware");
});
When I run and debug, I noticed that the above middleware is getting called twice. Later I figured out that second call is for favicon
. When the web API is launched in browser, I noticed from the network tab that browser is making favicon request automatically and the confusing thing is that favicon request succeeds even though I don't have favicon in my project.
Here is the link to project repo.
Is it something like browser will by default make favicon call? or there is an option to ignore favicon call? When it comes to ignore, the call will be made by browser and we need to ignore the request in code? or we can prevent the favicon call itself?
<link rel="icon" href="data:,">
– Logistics