Marvee Amasi
Marvee Amasi
DIIDevHeads IoT Integration Server
Created by Marvee Amasi on 6/7/2024 in #middleware-and-os
Is there any difference between the { e.MapControllers(); } and the e.MapControllers() ?
@Middleware & OS Hi everyone in C#, when using lambda expressions with the UseEndpoints method, what's the difference between including curly braces and omitting them? From my code example :
public void Configure(IApplicationBuilder app)
{
... //my other codes
app.UseEndpoints(e => e.MapControllers());

app.UseEndpoints(e => { e.MapControllers(); });
}
public void Configure(IApplicationBuilder app)
{
... //my other codes
app.UseEndpoints(e => e.MapControllers());

app.UseEndpoints(e => { e.MapControllers(); });
}
Is there any difference between the { e.MapControllers(); } and the e.MapControllers() ? And why would the MapControllers be called twice in this case?
5 replies