UseMVC.cs

public class Startup { public void Configure( IApplicationBuilder app, IHostingEnvironment env, ILoggerFactoryloggerFactory ) { // add default logging components loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); // Add the following to the request pipeline only in development environment. if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseErrorPage(); app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll); } else { // Add Error handling middleware which catches all application specific errors and // sends the request to the following path or controller action. app.UseErrorHandler("/Home/Error"); } // Add static files to the request pipeline. app.UseStaticFiles(); // Add cookie-based authentication to the request pipeline. app.UseIdentity(); // Add other middleware to the request pipeline here. // Add MVC to the request pipeline. app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); } }
The Startup class’s Configure method is used to add modules to the request pipeline. This is done by calling extension methods on the objects passed as arguments, as shown in Listing 1-7. UseMvc is an extension method on the IApplicationBuilder argument. Invoking UseMVC adds ASP.NET Core MVC to the request pipeline. A lambda expression passed as an argument to UseMVC is used to define the default routes for the application.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.