Skip to content

Instantly share code, notes, and snippets.

@manoj-choudhari-git
Created May 27, 2021 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manoj-choudhari-git/f237796604db5e66fff60148ab33554d to your computer and use it in GitHub Desktop.
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.
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