Created
May 27, 2021 22:34
-
-
Save manoj-choudhari-git/f237796604db5e66fff60148ab33554d to your computer and use it in GitHub Desktop.
.NET Core Web Application - Startup configuration showing routing template via UseEndpoints middleware.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Startup | |
{ | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
// Register service to add all controllers and views for routing | |
services.AddControllersWithViews(); | |
} | |
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) | |
{ | |
// some middlewares | |
app.UseRouting(); | |
// some more middlewares | |
app.UseEndpoints(endpoints => | |
{ | |
// Routing template | |
endpoints.MapControllerRoute( | |
name: "default", | |
pattern: "{controller=Home}/{action=Index}/{id?}"); | |
// Above is same as calling below method | |
// endpoints.MapDefaultControllerRoute() | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment