Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Builder;
- using Microsoft.AspNetCore.Hosting;
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.HttpsPolicy;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Configuration;
- using Microsoft.Extensions.DependencyInjection;
- using Projekt_PlatformyDoOrganizacjiWydarzen.Services;
- using Projekt_PlatformyDoOrganizacjiWydarzen.Entities;
- using Microsoft.EntityFrameworkCore;
- using Projekt_PlatformyDoOrganizacjiWydarzen.Models;
- using Projekt_PlatformyDoOrganizacjiWydarzen.Areas.Identity.Data;
- using Microsoft.AspNetCore.Identity;
- using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Mvc.RazorPages;
- namespace Projekt_PlatformyDoOrganizacjiWydarzen
- {
- 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)
- {
- services.Configure<EmailSettings>(Configuration.GetSection("EmailSettings"));
- services.Configure<CookiePolicyOptions>(options =>
- {
- // This lambda determines whether user consent for non-essential cookies is needed for a given request.
- options.CheckConsentNeeded = context => true;
- options.MinimumSameSitePolicy = SameSiteMode.None;
- });
- services.AddSingleton<IEmailSender, EmailSender>();
- services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
- services.AddDbContext<EventsContext>(options =>
- options.UseSqlServer(Configuration.GetConnectionString("EventsContext")));
- services.AddDbContext<TicketsContext>(options =>
- options.UseSqlServer(Configuration.GetConnectionString("TicketsContext")));
- services.AddDbContext<VerifyContext>(options =>
- options.UseSqlServer(Configuration.GetConnectionString("VerifyContext")));
- }
- // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
- public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicationDbContext context, RoleManager<IdentityRole> roleManager, UserManager<IdentityUser> userManager)
- {
- if (env.IsDevelopment())
- {
- app.UseDeveloperExceptionPage();
- app.UseBrowserLink();
- }
- else
- {
- app.UseExceptionHandler("/Home/Error");
- // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
- app.UseHsts();
- }
- app.UseHttpsRedirection();
- app.UseStaticFiles();
- app.UseCookiePolicy();
- app.UseAuthentication();
- app.UseMvc(routes =>
- {
- routes.MapRoute(
- name: "default",
- template: "{controller=Home}/{action=Index}/{id?}");
- });
- Roles.Initialize(context, userManager, roleManager)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement