WebApplication Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
The web application used to configure the HTTP pipeline, and routes.
public sealed class WebApplication : IAsyncDisposable, IDisposable, Microsoft.AspNetCore.Builder.IApplicationBuilder, Microsoft.AspNetCore.Routing.IEndpointRouteBuilder, Microsoft.Extensions.Hosting.IHost
type WebApplication = class
interface IHost
interface IDisposable
interface IApplicationBuilder
interface IEndpointRouteBuilder
interface IAsyncDisposable
Public NotInheritable Class WebApplication
Implements IApplicationBuilder, IAsyncDisposable, IDisposable, IEndpointRouteBuilder, IHost
- Inheritance
-
WebApplication
- Implements
Configuration |
The application's configured IConfiguration. |
Environment |
The application's configured IWebHostEnvironment. |
Lifetime |
Allows consumers to be notified of application lifetime events. |
Logger |
The default logger for the application. |
Services |
The application's configured services. |
Urls |
The list of URLs that the HTTP server is bound to. |
Create(String[]) |
Initializes a new instance of the WebApplication class with preconfigured defaults. |
Create |
Initializes a new instance of the WebApplicationBuilder class with preconfigured defaults. |
Create |
Initializes a new instance of the WebApplicationBuilder class with preconfigured defaults. |
Create |
Initializes a new instance of the WebApplicationBuilder class with preconfigured defaults. |
Create |
Initializes a new instance of the WebApplicationBuilder class with no defaults. |
Create |
Initializes a new instance of the WebApplicationBuilder class with minimal defaults. |
Create |
Initializes a new instance of the WebApplicationBuilder class with minimal defaults. |
Create |
Initializes a new instance of the WebApplicationBuilder class with minimal defaults. |
Dispose |
Disposes the application. |
Run(String) |
Runs an application and block the calling thread until host shutdown. |
Run |
Runs an application and returns a Task that only completes when the token is triggered or shutdown is triggered. |
Start |
Start the application. |
Stop |
Shuts down the application. |
Use(Func<Request |
Adds the middleware to the application request pipeline. |
Use |
Adds the anti-forgery middleware to the pipeline. |
Use |
Adds the RequestLocalizationMiddleware to automatically set culture information for requests based on information provided by the client. |
Use |
Adds the RequestLocalizationMiddleware to automatically set culture information for requests based on information provided by the client. |
Use |
Adds the RequestLocalizationMiddleware to automatically set culture information for requests based on information provided by the client. |
Use |
Adds the RequestLocalizationMiddleware to automatically set culture information for requests based on information provided by the client. |
Use |
Adds the AuthenticationMiddleware to the specified IApplicationBuilder, which enables authentication capabilities. |
Use |
Adds the AuthorizationMiddleware to the specified IApplicationBuilder, which enables authorization capabilities.
When authorizing a resource that is routed using endpoint routing, this call must appear between the calls to
|
Use |
Adds a middleware to the pipeline that will look for a certificate in a request header decode it, and updates HttpContext.Connection.ClientCertificate. |
Map |
Maps the Blazor Hub to the default path. |
Map |
Maps the Blazor Hub to the path |
Map |
Maps the Blazor Hub to the path |
Map |
Maps the Blazor Hub to the default path. |
Use |
Configures the application to serve Blazor WebAssembly framework files from the path |
Use |
Configures the application to serve Blazor WebAssembly framework files from the root path "/". |
Use |
Obsolete.
Adds the ConcurrencyLimiterMiddleware to limit the number of concurrently-executing requests. |
Map |
Maps incoming requests with the specified path to the provided connection pipeline. |
Map |
Maps incoming requests with the specified path to the provided connection pipeline. |
Map |
Maps incoming requests with the specified path to the provided connection pipeline. |
Map |
Maps incoming requests with the specified path to the provided connection pipeline. |
Map |
Adds endpoints for controller actions to the IEndpointRouteBuilder and specifies a route
with the given |
Map |
Adds endpoints for controller actions to the IEndpointRouteBuilder and specifies a route
with the given |
Map |
Adds endpoints for controller actions to the IEndpointRouteBuilder without specifying any routes. |
Map |
Adds endpoints for controller actions to the IEndpointRouteBuilder and adds the default route
|
Map |
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will
attempt to select a controller action using the route values produced by |
Map |
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will
attempt to select a controller action using the route values produced by |
Map |
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will
attempt to select a controller action using the route values produced by |
Map |
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will match
requests for non-file-names with the lowest possible priority. The request will be routed to a controller endpoint that
matches |
Map |
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will match
requests for non-file-names with the lowest possible priority. The request will be routed to a controller endpoint that
matches |
Map |
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will match
requests for non-file-names with the lowest possible priority. The request will be routed to a controller endpoint that
matches |
Map |
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will match
requests for non-file-names with the lowest possible priority. The request will be routed to a controller endpoint that
matches |
Use |
Adds the CookiePolicyMiddleware handler to the specified IApplicationBuilder, which enables cookie policy capabilities. |
Use |
Adds the CookiePolicyMiddleware handler to the specified IApplicationBuilder, which enables cookie policy capabilities. |
Use |
Adds a CORS middleware to your web application pipeline to allow cross domain requests. |
Use |
Adds a CORS middleware to your web application pipeline to allow cross domain requests. |
Use |
Adds a CORS middleware to your web application pipeline to allow cross domain requests. |
Use |
Obsolete.
Captures synchronous and asynchronous database related exceptions from the pipeline that may be resolved using Entity Framework migrations. When these exceptions occur, an HTML response with details of possible actions to resolve the issue is generated. |
Use |
Obsolete.
Captures synchronous and asynchronous database related exceptions from the pipeline that may be resolved using Entity Framework migrations. When these exceptions occur, an HTML response with details of possible actions to resolve the issue is generated. |
Use |
Enables default file mapping with the given options |
Use |
Enables default file mapping for the given request path |
Use |
Enables default file mapping on the current path |
Use |
Captures synchronous and asynchronous Exception instances from the pipeline and generates HTML error responses. |
Use |
Captures synchronous and asynchronous Exception instances from the pipeline and generates HTML error responses. |
Use |
Enable directory browsing with the given options |
Use |
Enables directory browsing for the given request path |
Use |
Enable directory browsing on the current path |
Map(IEndpoint |
Adds a RouteEndpoint to the IEndpointRouteBuilder that matches HTTP requests for the specified pattern. |
Map(IEndpoint |
Adds a RouteEndpoint to the IEndpointRouteBuilder that matches HTTP requests for the specified pattern. |
Map(IEndpoint |
Adds a RouteEndpoint to the IEndpointRouteBuilder that matches HTTP requests for the specified pattern. |
Map(IEndpoint |
Adds a RouteEndpoint to the IEndpointRouteBuilder that matches HTTP requests for the specified pattern. |
Map |
Adds a RouteEndpoint to the IEndpointRouteBuilder that matches HTTP DELETE requests for the specified pattern. |
Map |
Adds a RouteEndpoint to the IEndpointRouteBuilder that matches HTTP DELETE requests for the specified pattern. |
Map |
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will match requests for non-file-names with the lowest possible priority. |
Map |
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will match the provided pattern with the lowest possible priority. |
Map |
Adds a RouteEndpoint to the IEndpointRouteBuilder that matches HTTP GET requests for the specified pattern. |
Map |
Adds a RouteEndpoint to the IEndpointRouteBuilder that matches HTTP GET requests for the specified pattern. |
Map |
Creates a RouteGroupBuilder for defining endpoints all prefixed with the specified |
Map |
Creates a RouteGroupBuilder for defining endpoints all prefixed with the specified |
Map |
Adds a RouteEndpoint to the IEndpointRouteBuilder that matches HTTP requests for the specified HTTP methods and pattern. |
Map |
Adds a RouteEndpoint to the IEndpointRouteBuilder that matches HTTP requests for the specified HTTP methods and pattern. |
Map |
Adds a RouteEndpoint to the IEndpointRouteBuilder that matches HTTP PATCH requests for the specified pattern. |
Map |
Adds a RouteEndpoint to the IEndpointRouteBuilder that matches HTTP PATCH requests for the specified pattern. |
Map |
Adds a RouteEndpoint to the IEndpointRouteBuilder that matches HTTP POST requests for the specified pattern. |
Map |
Adds a RouteEndpoint to the IEndpointRouteBuilder that matches HTTP POST requests for the specified pattern. |
Map |
Adds a RouteEndpoint to the IEndpointRouteBuilder that matches HTTP PUT requests for the specified pattern. |
Map |
Adds a RouteEndpoint to the IEndpointRouteBuilder that matches HTTP PUT requests for the specified pattern. |
Use |
Adds a Microsoft.AspNetCore.Routing.EndpointMiddleware middleware to the specified IApplicationBuilder with the EndpointDataSource instances built from configured IEndpointRouteBuilder. The Microsoft.AspNetCore.Routing.EndpointMiddleware will execute the Endpoint associated with the current request. |
Use |
Adds a Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware middleware to the specified IApplicationBuilder. |
Use |
Adds a middleware to the pipeline that will catch exceptions, log them, and re-execute the request in an alternate pipeline. The request will not be re-executed if the response has already started. |
Use |
Adds a middleware to the pipeline that will catch exceptions, log them, and re-execute the request in an alternate pipeline. The request will not be re-executed if the response has already started. |
Use |
Adds a middleware to the pipeline that will catch exceptions, log them, reset the request path, and re-execute the request. The request will not be re-executed if the response has already started. |
Use |
Adds a middleware to the pipeline that will catch exceptions, log them, reset the request path, and re-execute the request. The request will not be re-executed if the response has already started. |
Use |
Adds a middleware to the pipeline that will catch exceptions, log them, and re-execute the request in an alternate pipeline. The request will not be re-executed if the response has already started. |
Map |
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will match requests for non-file-names with the lowest possible priority. |
Map |
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will match the provided pattern with the lowest possible priority. |
Use |
Enable all static file middleware with the given options |
Use |
Enable all static file middleware on for the current request path in the current directory. |
Use |
Enables all static file middleware (except directory browsing) for the given request path from the directory of the same name |
Use |
Enable all static file middleware (except directory browsing) for the current request path in the current directory. |
Use |
Applies forwarded headers to their matching fields on the current request. By convention, HTTP proxies forward information from the client in well-known HTTP headers. The ForwardedHeadersMiddleware reads these headers and fills in the associated fields on HttpContext. |
Use |
Applies forwarded headers to their matching fields on the current request. By convention, HTTP proxies forward information from the client in well-known HTTP headers. The ForwardedHeadersMiddleware reads these headers and fills in the associated fields on HttpContext. |
Use |
Adds a middleware that collect headers to be propagated to a HttpClient. |
Use |
Adds a middleware that provides health check status. |
Use |
Adds a middleware that provides health check status. |
Use |
Adds a middleware that provides health check status. |
Use |
Adds a middleware that provides health check status. |
Use |
Adds a middleware that provides health check status. |
Use |
Adds a middleware that provides health check status. |
Map |
Adds a health checks endpoint to the IEndpointRouteBuilder with the specified template and options. |
Map |
Adds a health checks endpoint to the IEndpointRouteBuilder with the specified template. |
Use |
Adds middleware for filtering requests by allowed host headers. Invalid requests will be rejected with a 400 status code. |
Use |
Adds middleware for using HSTS, which adds the Strict-Transport-Security header. |
Use |
Adds a middleware that can log HTTP requests and responses. |
UseW3CLogging(IApplication |
Adds a middleware that can log HTTP requests and responses for server logs in W3C format. |
Use |
Allows incoming POST request to override method type with type specified in form. This middleware is used when a client is limited to sending GET or POST methods but wants to invoke other HTTP methods. |
Use |
Allows incoming POST request to override method type with type specified in header. This middleware is used when a client is limited to sending GET or POST methods but wants to invoke other HTTP methods. By default, the X-HTTP-Method-Override request header is used to specify the HTTP method being tunneled. |
Use |
Adds middleware for redirecting HTTP Requests to HTTPS. |
Map |
Maps incoming requests with the specified path to the specified Hub type. |
Map |
Maps incoming requests with the specified path to the specified Hub type. |
Map(IApplication |
Branches the request pipeline based on matches of the given request path. If the request path starts with the given path, the branch is executed. |
Map(IApplication |
Branches the request pipeline based on matches of the given request path. If the request path starts with the given path, the branch is executed. |
Map(IApplication |
Branches the request pipeline based on matches of the given request path. If the request path starts with the given path, the branch is executed. |
Map |
Branches the request pipeline based on the result of the given predicate. |
Use |
Processes requests to execute migrations operations. The middleware will listen for requests to the path configured in |
Use |
Processes requests to execute migrations operations. The middleware will listen for requests made to DefaultPath. |
Use |
Adds MVC to the IApplicationBuilder request execution pipeline. |
Use |
Adds MVC to the IApplicationBuilder request execution pipeline. |
Use |
Adds MVC to the IApplicationBuilder request execution pipeline with a default route named 'default' and the following template: '{controller=Home}/{action=Index}/{id?}'. |
Map |
Register an endpoint onto the current application for resolving the OpenAPI document associated with the current application. |
Use |
Adds the Microsoft.AspNetCore.OutputCaching.OutputCacheMiddleware for caching HTTP responses. |
Use |
Adds OWIN middleware pipeline to the specified IApplicationBuilder. |
Use |
Adds an OWIN pipeline to the specified IApplicationBuilder. |
Use |
Enables rate limiting for the application. |
Use |
Enables rate limiting for the application. |
Map |
Maps the page components defined in the specified |
Map |
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will
attempt to select a page using the route values produced by |
Map |
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will
attempt to select a page using the route values produced by |
Map |
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will
attempt to select a page using the route values produced by |
Map |
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will match
requests for non-file-names with the lowest possible priority. The request will be routed to a page endpoint that
matches |
Map |
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will match
requests for non-file-names with the lowest possible priority. The request will be routed to a page endpoint that
matches |
Map |
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will match
requests for non-file-names with the lowest possible priority. The request will be routed to a page endpoint that
matches |
Map |
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will match
requests for non-file-names with the lowest possible priority. The request will be routed to a page endpoint that
matches |
Map |
Adds endpoints for Razor Pages to the IEndpointRouteBuilder. |
Use |
Adds middleware for dynamically decompressing HTTP request bodies. |
Use |
Enables request timeouts for the application. No timeouts are configured by default. They must be configured in RequestTimeoutOptions, the RequestTimeoutAttribute on endpoints, or using the WithRequestTimeout routing extensions. |
Use |
Adds the ResponseCachingMiddleware for caching HTTP responses. |
Use |
Adds middleware for dynamically compressing HTTP Responses. |
Use |
Checks if a given Url matches rules and conditions, and modifies the HttpContext on match. |
Use |
Checks if a given Url matches rules and conditions, and modifies the HttpContext on match. |
Use |
Adds a RouterMiddleware middleware to the specified IApplicationBuilder with the specified IRouter. |
Use |
Adds a RouterMiddleware middleware to the specified IApplicationBuilder with the IRouter built from configured IRouteBuilder. |
Run(IApplication |
Adds a terminal middleware delegate to the application's request pipeline. |
Use |
Adds the SessionMiddleware to automatically enable session state for the application. |
Use |
Adds the SessionMiddleware to automatically enable session state for the application. |
Use |
Handles all requests from this point in the middleware chain by returning the default page for the Single Page Application (SPA). This middleware should be placed late in the chain, so that other middleware for serving static files, MVC actions, etc., takes precedence. |
Map |
Maps static files produced during the build as endpoints. |
Use |
Enables static file serving with the given options |
Use |
Enables static file serving for the given request path |
Use |
Enables static file serving for the current request path |
Map |
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will match
requests for non-filenames with the lowest possible priority. The request will be routed to a
StaticFileMiddleware that attempts to serve the file specified by |
Map |
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will match
requests for non-filenames with the lowest possible priority. The request will be routed to a
StaticFileMiddleware that attempts to serve the file specified by |
Map |
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will match
requests for non-filenames with the lowest possible priority. The request will be routed to a
StaticFileMiddleware that attempts to serve the file specified by |
Map |
Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will match
requests for non-filenames with the lowest possible priority. The request will be routed to a
StaticFileMiddleware that attempts to serve the file specified by |
Use |
Adds a StatusCodePages middleware with the given options that checks for responses with status codes between 400 and 599 that do not have a body. |
Use |
Adds a StatusCodePages middleware to the pipeline with the specified alternate middleware pipeline to execute to generate the response body. |
Use |
Adds a StatusCodePages middleware with the specified handler that checks for responses with status codes between 400 and 599 that do not have a body. |
Use |
Adds a StatusCodePages middleware with the specified response body to send. This may include a '{0}' placeholder for the status code. The middleware checks for responses with status codes between 400 and 599 that do not have a body. |
Use |
Adds a StatusCodePages middleware with a default response handler that checks for responses with status codes between 400 and 599 that do not have a body. |
Use |
Adds a StatusCodePages middleware to the pipeline. Specifies that responses should be handled by redirecting with the given location URL template. This may include a '{0}' placeholder for the status code. URLs starting with '~' will have PathBase prepended, where any other URL will be used as is. |
Use |
Adds a StatusCodePages middleware to the pipeline. Specifies that the response body should be generated by re-executing the request pipeline using an alternate path. This path may contain a '{0}' placeholder of the status code. |
Use(IApplication |
Adds a middleware delegate defined in-line to the application's request pipeline. If you aren't calling the next function, use Run(IApplicationBuilder, RequestDelegate) instead. |
Use(IApplication |
Adds a middleware delegate defined in-line to the application's request pipeline. If you aren't calling the next function, use Run(IApplicationBuilder, RequestDelegate) instead. Prefer using Use(IApplicationBuilder, Func<HttpContext,RequestDelegate,Task>) for better performance as shown below:
|
Use |
Adds a middleware type to the application's request pipeline. |
Use |
Adds a middleware type to the application's request pipeline. |
Use |
Adds a middleware that extracts the specified path base from request path and postpend it to the request path base. |
Use |
Conditionally creates a branch in the request pipeline that is rejoined to the main pipeline. |
Use |
Adds middleware needed for debugging Blazor WebAssembly applications inside Chromium dev tools. |
Use |
Adds the WebSocketMiddleware to the request pipeline. |
Use |
Adds the WebSocketMiddleware to the request pipeline. |
Use |
Adds the WelcomePageMiddleware to the pipeline with the given options. |
Use |
Adds the WelcomePageMiddleware to the pipeline with the given path. |
Use |
Adds the WelcomePageMiddleware to the pipeline with the given path. |
Use |
Adds the WelcomePageMiddleware to the pipeline. |
Map |
Add endpoints for registering, logging in, and logging out using ASP.NET Core Identity. |
Map |
Adds a RouteEndpoint to the IEndpointRouteBuilder that matches HTTP requests (all verbs) for the specified prefixes. |
Use |
Registers incoming HTTP request logging middleware into IApplicationBuilder. |
Use |
Registers Request Checkpoint related middlewares into the pipeline. |
Use |
Adds the request latency telemetry middleware to IApplicationBuilder request execution pipeline. |
Use |
Configures the application to serve static files for a Single Page Application (SPA). The files will be located using the registered ISpaStaticFileProvider service. |
Use |
Configures the application to serve static files for a Single Page Application (SPA). The files will be located using the registered ISpaStaticFileProvider service. |