ifinox

Untitled

May 16th, 2018
542
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.22 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Security.Principal;
  5. using System.Threading.Tasks;
  6. using Microsoft.AspNetCore.Authentication.Cookies;
  7. using Microsoft.AspNetCore.Builder;
  8. using Microsoft.AspNetCore.Hosting;
  9. using Microsoft.AspNetCore.Http;
  10. using Microsoft.AspNetCore.Identity;
  11. using Microsoft.EntityFrameworkCore;
  12. using Microsoft.Extensions.Configuration;
  13. using Microsoft.Extensions.DependencyInjection;
  14. using Test.Web.Interfaces;
  15. using Test.Web.Services;
  16. namespace Test.Web
  17. {
  18.     public class Startup
  19.     {
  20.         public Startup(IConfiguration configuration)
  21.         {
  22.             Configuration = configuration;
  23.         }
  24.  
  25.         public IConfiguration Configuration { get; }
  26.  
  27.         // This method gets called by the runtime. Use this method to add services to the container.
  28.         public void ConfigureServices(IServiceCollection services)
  29.         {
  30.             services.AddMvc(options => {
  31.                 options.ModelBinderProviders.Insert(0, new CustomBinderProvider());
  32.             });
  33.  
  34.  
  35.             services.AddDbContext<ApplicationDbContext>(o =>
  36.                 o.UseSqlite(Configuration.GetConnectionString("DefaultConnection")), ServiceLifetime.Scoped);
  37.  
  38.             services.AddScoped<IUserRepo, UserRepo>();
  39.             services.AddScoped<IRoleRepo, RoleRepo>();
  40.            
  41.             services.AddSingleton<IUserCache, UserCache>();
  42.             services.AddScoped<ICaptchaVerification, CaptchaVerification>();
  43.         }
  44.  
  45.         // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  46.         public void Configure(IApplicationBuilder app,
  47.             IHostingEnvironment env)
  48.         {
  49.             if (env.IsDevelopment())
  50.             {
  51.                 app.UseDeveloperExceptionPage();
  52.             }
  53.             else
  54.             {
  55.                 app.UseExceptionHandler("/Home/Error");
  56.             }
  57.            
  58.             app.UseStaticFiles();
  59.            
  60.  
  61.             app.UseMvc(routes =>
  62.             {
  63.  
  64.                 routes.MapRoute(
  65.                     name: "default",
  66.                     template: "{controller=Home}/{action=Index}/{id?}");
  67.             });
  68.         }
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment