Answer: Configure method defines the middleware in the Http request pipeline. The software components that are assembled into an application pipeline to handle requests and responses are the middlewares.
E.g.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseApplicationInsightsRequestTelemetry();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseApplicationInsightsExceptionTelemetry();
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
In the above code,UseExceptionHandler is a middleware. It is added as a middleware to the pipeline that will catch exceptions, log them, reset the request path, and re-execute the request.
Asked In: Many Interviews |
Alert Moderator