Skip to content

Instantly share code, notes, and snippets.

@pradeepn
Created March 20, 2024 06:44
Show Gist options
  • Save pradeepn/c9250b31c06b779ad0b59884f51e3796 to your computer and use it in GitHub Desktop.
Save pradeepn/c9250b31c06b779ad0b59884f51e3796 to your computer and use it in GitHub Desktop.
ASP.NET Core 2.1 Bootstrapping
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment