namespace UC.AppRepository.UI
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddHttpClient();
services.AddRazorPages();
services.AddServerSideBlazor();
services.AddHttpClient();
services.AddAutoMapper(typeof(Startup));
//Configration
services.Configure<Schema>(Configuration.GetSection("Schema"));
services.Configure<DBConnectionAppIds>(Configuration.GetSection("DBConnectionAppIds"));
//DB Context
var connection = new DBCredentials().GetConnectionString(Configuration["DBConnectionAppIds:AppID"]);
connection = connection + "TrustServerCertificate=True;";
services.AddDbContext<AppsRepositoryDBContext>(options => options.UseSqlServer(connection));
services.AddTransient(typeof(IRepository<>), typeof(BaseRepository<>));
services.AddControllers();
//Identity Authentication
services.AddIdentity<IdentityUser, IdentityRole>(Option => Option.SignIn.RequireConfirmedAccount = false)
.AddDefaultUI()
.AddDefaultTokenProviders()
.AddEntityFrameworkStores<AppsRepositoryDBContext>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/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.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapBlazorHub();
endpoints.MapFallbackToPage("/_Host");
});
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}Browse