In .Net Core web application initialization and startup has been totally changed.
Configure Method of Startup class configures Http Request pipeline.
Middleware
Middleware is software that's assembled into an app pipeline to handle requests and responses.
Run, Map and Use methods
Run: First occurrence of Run terminates the executor branch or request pipeline if no branches.
Configure Method of Startup class configures Http Request pipeline.
- Global.asax has been removed.
- ini, xml and json files taken place to use in configuration
Middleware
Middleware is software that's assembled into an app pipeline to handle requests and responses.
- A Middleware can choose whether the request has to pass to next component or it can terminate the chain that is called Short-Circuiting the pipeline. Middleware3 is doing it in below example.
- Middleware can perform work before calling next component and can perform work after the next component call finishes.
Run, Map and Use methods
Run: First occurrence of Run terminates the executor branch or request pipeline if no branches.
public class Startup
{
public
void Configure(IApplicationBuilder app)
{
app.Run(async
context =>
{
await
context.Response.WriteAsync("Hello megabyteland.blogspot.com");
});
}
}
Use: To configure multiple middlewares you need to use Use method. Second parameter of Use is delegate for next middleware defined in the pipeline.
public class Startup
{
public
void Configure(IApplicationBuilder app)
{
app.Use(async
(context, next) =>
{
// Do work before invoking next middleware.
await
next.Invoke();
// Do work after invoking next middleware.
});
app.Run(async
context =>
{
await
context.Response.WriteAsync(("Hello megabyteland.blogspot.com");
});
}
}
}












