Skip to content

Instantly share code, notes, and snippets.

@saurabhpati
Last active January 25, 2018 05:00
Show Gist options
  • Save saurabhpati/295ea54e8c2bbcf7559911c7e76ccaeb to your computer and use it in GitHub Desktop.
Save saurabhpati/295ea54e8c2bbcf7559911c7e76ccaeb to your computer and use it in GitHub Desktop.
Startup class
public class Startup
{
// Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IDependecy, Dependency>()
.AddScoped<UserManager<AppUser>>()
.AddTransient<IUserClaimsPrincipalFactory<AppUser>, AppUserClaimsPrincipalFactory>();
}
// Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHsts(option => option.MaxAge(days: 10)) // Using http strict transport security protocol.
.UseCsp(option => option.DefaultSources(source => source.Self())) // Using content security protocol for anti xss.
.UseXfo(option => option.Deny()) // Denying X-Frames to run on the site to prevent click-jacking.
.UseStaticFiles()
.UseStatusCodePages()
.UseAuthentication()
.UseMvc(route => route.MapRoute(name: "default", template: "{Controller=HomeController}/{Action=Index}/{id?}"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment