Cookie Authentication

Cookie Authentication رایج‌ترین روش احراز هویت در برنامه‌های MVC است. پس از ورود کاربر، اطلاعات ورود در یک Cookie رمزنگاری‌شده ذخیره می‌شود.

فعال‌سازی Cookie Authentication


builder.Services
    .AddAuthentication("Cookies")
    .AddCookie();

ورود کاربر


await HttpContext.SignInAsync(
    "Cookies",
    principal);

خروج کاربر


await HttpContext.SignOutAsync("Cookies");

جمع‌بندی

Cookie Authentication روشی ساده و ایمن برای مدیریت ورود کاربران در برنامه‌های مبتنی بر MVC و Razor Pages است.