
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Use of Configure Method in Startup Class in C# ASP.NET Core
The configure method is present inside startup class of ASP.NET Core application
The Configure method is a place where you can configure application request pipeline for your application using IApplicationBuilder instance that is provided by the built-in IoC container
The Configure method by default has these three parameters IApplicationBuilder, IWebHostEnvironment and ILoggerFactory .
At run time, the ConfigureServices method is called before the Configure method. This is to register custom service with the IoC container which can be used in Configure method.
IWebHostEnvironment :Provides information about the web hosting environment an application is running in.
IApplicationBuilder:Defines a class that provides the mechanisms to configure an application's request pipeline.
Example
public void Configure(IApplicationBuilder app, IWebHostEnvironment env){ if (env.IsDevelopment()){ app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints =>{ endpoints.MapRazorPages(); }); }