Add project files.
This commit is contained in:
64
ConstructorAppUI/Program.cs
Normal file
64
ConstructorAppUI/Program.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using ConstructorApp.BusinessLayer.Abstract;
|
||||
using ConstructorApp.BusinessLayer.Concrete;
|
||||
using ConstructorApp.DataAccessLayer.Abstract;
|
||||
using ConstructorApp.DataAccessLayer.Concrete;
|
||||
using ConstructorApp.DataAccessLayer.EntityFramework;
|
||||
using ConstructorApp.EntityLayer.Entities;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc.Authorization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
//Proje seviyesinde Authentication
|
||||
var requireAuthorizePolicy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build();
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddDbContext<ConstructorContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("mssql")));
|
||||
|
||||
// IFooterService ve FooterService servisini ekleyin
|
||||
builder.Services.AddScoped<IFooterService, FooterManager>();
|
||||
builder.Services.AddScoped<IFooterDal, EfFooterDal>();
|
||||
|
||||
builder.Services.AddIdentity<AppUser, AppRole>()
|
||||
.AddEntityFrameworkStores<ConstructorContext>()
|
||||
.AddDefaultTokenProviders();
|
||||
builder.Services.AddHttpClient();
|
||||
|
||||
//T<>m projede kullan<61>c<EFBFBD>lar<61> login olmaya zorla
|
||||
builder.Services.AddControllersWithViews(opt =>
|
||||
{
|
||||
opt.Filters.Add(new AuthorizeFilter(requireAuthorizePolicy));
|
||||
});
|
||||
|
||||
//Login sayfas<61>n<EFBFBD> default olan Account/Login yerine kendi login sayfama y<>nlendir
|
||||
builder.Services.ConfigureApplicationCookie(opts =>
|
||||
{
|
||||
opts.LoginPath = "/Login/Index/";
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
//app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseAuthentication();
|
||||
|
||||
app.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||
|
||||
app.Run();
|
||||
Reference in New Issue
Block a user