Advertisement
Guest User

Untitled

a guest
May 20th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Microsoft.AspNetCore.Builder;
  6. using Microsoft.AspNetCore.Hosting;
  7. using Microsoft.AspNetCore.Http;
  8. using Microsoft.AspNetCore.HttpsPolicy;
  9. using Microsoft.AspNetCore.Mvc;
  10. using Microsoft.Extensions.Configuration;
  11. using Microsoft.Extensions.DependencyInjection;
  12. using Projekt_PlatformyDoOrganizacjiWydarzen.Services;
  13. using Projekt_PlatformyDoOrganizacjiWydarzen.Entities;
  14. using Microsoft.EntityFrameworkCore;
  15. using Projekt_PlatformyDoOrganizacjiWydarzen.Models;
  16. using Projekt_PlatformyDoOrganizacjiWydarzen.Areas.Identity.Data;
  17. using Microsoft.AspNetCore.Identity;
  18. using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
  19. using Microsoft.AspNetCore.Authorization;
  20. using Microsoft.AspNetCore.Mvc.RazorPages;
  21.  
  22. namespace Projekt_PlatformyDoOrganizacjiWydarzen
  23. {
  24. public class Startup
  25. {
  26. public Startup(IConfiguration configuration)
  27. {
  28. Configuration = configuration;
  29. }
  30.  
  31. public IConfiguration Configuration { get; }
  32.  
  33. // This method gets called by the runtime. Use this method to add services to the container.
  34. public void ConfigureServices(IServiceCollection services)
  35. {
  36. services.Configure<EmailSettings>(Configuration.GetSection("EmailSettings"));
  37. services.Configure<CookiePolicyOptions>(options =>
  38. {
  39. // This lambda determines whether user consent for non-essential cookies is needed for a given request.
  40. options.CheckConsentNeeded = context => true;
  41. options.MinimumSameSitePolicy = SameSiteMode.None;
  42. });
  43.  
  44. services.AddSingleton<IEmailSender, EmailSender>();
  45. services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
  46.  
  47. services.AddDbContext<EventsContext>(options =>
  48. options.UseSqlServer(Configuration.GetConnectionString("EventsContext")));
  49.  
  50. services.AddDbContext<TicketsContext>(options =>
  51. options.UseSqlServer(Configuration.GetConnectionString("TicketsContext")));
  52.  
  53. services.AddDbContext<VerifyContext>(options =>
  54. options.UseSqlServer(Configuration.GetConnectionString("VerifyContext")));
  55.  
  56.  
  57.  
  58.  
  59. }
  60.  
  61. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  62. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicationDbContext context, RoleManager<IdentityRole> roleManager, UserManager<IdentityUser> userManager)
  63. {
  64. if (env.IsDevelopment())
  65. {
  66. app.UseDeveloperExceptionPage();
  67. app.UseBrowserLink();
  68. }
  69. else
  70. {
  71. app.UseExceptionHandler("/Home/Error");
  72. // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
  73. app.UseHsts();
  74. }
  75.  
  76.  
  77. app.UseHttpsRedirection();
  78. app.UseStaticFiles();
  79. app.UseCookiePolicy();
  80. app.UseAuthentication();
  81. app.UseMvc(routes =>
  82. {
  83. routes.MapRoute(
  84. name: "default",
  85. template: "{controller=Home}/{action=Index}/{id?}");
  86. });
  87. Roles.Initialize(context, userManager, roleManager)
  88.  
  89. }
  90.  
  91.  
  92. }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement