Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace P2PChat.Web
- {
- using Microsoft.AspNetCore.Builder;
- using Microsoft.AspNetCore.Identity;
- using Microsoft.EntityFrameworkCore;
- using Microsoft.AspNetCore.Hosting;
- using Microsoft.Extensions.Configuration;
- using Microsoft.Extensions.DependencyInjection;
- using P2PChat.Web.Data;
- using P2PChat.Web.Models;
- using P2PChat.Web.Services;
- using P2PChat.Web.Contracts;
- using P2PChat.Web.Hubs;
- 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.AddDbContext<ApplicationDbContext>(options =>
- options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
- services.AddIdentity<ApplicationUser, IdentityRole>()
- .AddEntityFrameworkStores<ApplicationDbContext>()
- .AddDefaultTokenProviders();
- // Add application services.
- services.AddTransient<IEmailSender, EmailSender>();
- services.AddSingleton<IChatConnectionService, ChatConnectionService>();
- services.AddMvc();
- services.AddSignalR();
- services.AddAuthentication().AddCookie();
- }
- // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
- public void Configure(IApplicationBuilder app, IHostingEnvironment env)
- {
- if (env.IsDevelopment())
- {
- app.UseDeveloperExceptionPage();
- app.UseBrowserLink();
- app.UseDatabaseErrorPage();
- }
- else
- {
- app.UseExceptionHandler("/Home/Error");
- }
- app.UseStaticFiles();
- app.UseAuthentication();
- app.UseSignalR(routes =>
- {
- routes.MapHub<ChatHub>("chat");
- });
- app.UseMvc(routes =>
- {
- routes.MapRoute(
- name: "default",
- template: "{controller=Home}/{action=Index}/{id?}");
- });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement