با سلام و خسته نباشید خدمت استاد گرامی آقای اردوخانی عزیز
من دوره شمارو همه رو مو به مو انجام دادم و پیش رفتم اما حالا یه مشکلی پیش اومده و نمیتونم قالب ادمین که انتقال دادم رو ببینم
پیکربندی فایل Program.cs رو براتون همین جا میزارم و ممنون میشم اگر منو راهنمایی کنید
با تشکر
var builder = WebApplication.CreateBuilder(args);
#region ConnectionString
builder.Services.AddDbContext<MarketPlaceDbContext>(options =>
{
options.UseSqlServer(builder.Configuration.GetConnectionString("MarketPlaceConnection"));
});
#endregion
#region Services
// Add services to the container.
builder.Services.AddControllersWithViews();
builder.Services.AddScoped(typeof(IGenericRepository<>), typeof(GenericRepository<>));
builder.Services.AddScoped<IUserService, UserService>();
builder.Services.AddScoped<ISiteService,SiteService>();
builder.Services.AddScoped<IPasswordHelper, PasswordHelper>();
builder.Services.AddHttpClient<ICaptchaValidator, GoogleReCaptchaValidator>();
builder.Services.AddScoped<ISmsService, SmsService>();
builder.Services.AddScoped<IContactService , ContactService>();
builder.Services.AddScoped<ISellerService, SellerService>();
#endregion
#region Authetication
builder.Services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
}).AddCookie(options =>
{
options.LoginPath = "/Login";
options.LogoutPath = "/Logout";
options.ExpireTimeSpan = TimeSpan.FromDays(7);
});
//app.UseAuthentication();
#endregion
#region HTMLEncoder
builder.Services.AddSingleton<HtmlEncoder>(HtmlEncoder.Create(allowedRanges: new[] { UnicodeRanges.BasicLatin, UnicodeRanges.Arabic }));
#endregion
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/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.UseAuthentication();
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.MapStaticAssets();
app.MapControllerRoute(
name:"areas",
pattern: "{areas:exists}/{controller=Home}/{actoion=Index}/{id?}"
);
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}")
.WithStaticAssets();
app.Run();
سلام خدمت شما دوست عزیز
باید area ادمین رو ایجاد کرده باشید و همینطور برای controller های این area باید از Area Attribute استفاده کنید:
[Area("Admin")]
public class AdminController : ControllerBase {...}