AntiForgeryController.cs 721 B

1234567891011121314151617181920212223242526272829
  1. using Abp.Web.Security.AntiForgery;
  2. using Microsoft.AspNetCore.Antiforgery;
  3. using VberAdmin.Controllers;
  4. namespace VberAdmin.Web.Host.Controllers;
  5. public class AntiForgeryController : VberAdminControllerBase
  6. {
  7. private readonly IAntiforgery _antiforgery;
  8. private readonly IAbpAntiForgeryManager _antiForgeryManager;
  9. public AntiForgeryController(IAntiforgery antiforgery, IAbpAntiForgeryManager antiForgeryManager)
  10. {
  11. _antiforgery = antiforgery;
  12. _antiForgeryManager = antiForgeryManager;
  13. }
  14. public void GetToken()
  15. {
  16. _antiforgery.SetCookieTokenAndHeader(HttpContext);
  17. }
  18. public void SetCookie()
  19. {
  20. _antiForgeryManager.SetCookie(HttpContext);
  21. }
  22. }