Skip to content

Instantly share code, notes, and snippets.

@ozgurrgul
Created October 24, 2017 06:41
Show Gist options
  • Save ozgurrgul/4077f7be962eb8837f26d981dc7f25b3 to your computer and use it in GitHub Desktop.
Save ozgurrgul/4077f7be962eb8837f26d981dc7f25b3 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
using WebApiJwt.Entities;
namespace WebApiJwt
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// ===== Add our DbContext ========
services.AddDbContext<ApplicationDbContext>();
// ===== Add Identity ========
services.AddIdentity<IdentityUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
// ===== Add MVC ========
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,
ApplicationDbContext dbContext
)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseMvc();
// ===== Create tables ======
dbContext.Database.EnsureCreated();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment