Interviews - C# Corner

Rajesh Gami
What Configure() method does in Startup.cs?
By Rajesh Gami in ASP.NET Core onApr 14 2018
  • Rajesh Gami
    Apr, 2018 14

    The Configure method is used to specify how the ASP.NET application will respond to HTTP requests. The request pipeline is configured by adding middleware components to an IApplicationBuilder instance that is provided by dependency injection. There are some built-in middlewares for error handling, authentication, routing, session and diagnostic purpose. Highlighted lines in below code, are built-in Middleware with ASP.NET Core 1.0.public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) {loggerFactory.AddConsole(Configuration.GetSection("Logging"));loggerFactory.AddDebug();app.UseApplicationInsightsRequestTelemetry();if (env.IsDevelopment()){app.UseBrowserLink();app.UseDeveloperExceptionPage();}else{app.UseExceptionHandler("/Home/Error");// For more details on creating database during deployment see http://go.microsoft.com/fwlink/?LinkID=615859try{using (var serviceScope = app.ApplicationServices.GetRequiredService().CreateScope()){serviceScope.ServiceProvider.GetService().Database.Migrate();}}catch { }}app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());app.UseStaticFiles();app.UseIdentity();// To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715app.UseMvc(routes =>{routes.MapRoute(name: "default",template: "{controller=Home}/{action=Index}/{id?}");}); }

    • 0

Most Popular Companies

Most Popular Job Functions

MOST LIKED QUESTIONS