We know how middleware components are added to the request pipeline, but how do we know which methods are available for use? We can find this answer by examining the IApplicationBuilder
interface.
Remember the Configure()
method we discussed in the previous lesson? The Configure()
method accepts an IApplicationBuilder
interface as a parameter:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
The IApplicationBuilder
interface provides the built-in middleware methods. These methods take the format UseX()
with X
describing the action performed by the method. There are five UseX()
methods highlighted in the example below. We’ll examine them in more detail a little later.
UseHttpsRedirection()
redirects HTTP requests to the more secure HTTPS protocolUseStaticFiles()
allows static files, like CSS and images, to be servedUseRouting()
allows route matchingUseAuthorization()
ensures requests are authorizedUseEndpoints()
adds endpoint execution to the middleware pipeline. It runs the code associated with the selected endpoint.
Note: There are several other built-in middleware components. Visit the IApplicationBuilder
documentation to see a complete list.
Instructions
View the IApplicationBuilder
documentation to see a complete list of the built-in middleware components available
via the IApplicationBuilder interface.
In this video, we go to the documentation to find the UseWelcomePage()
middleware.