how to implemetn CSRF token on aspnet zero with angualr front end on all pages post login
3 Answer(s)
-
0
Hi @amasanad
If you want to do this, you host your Angular app under your Web.Host app or you can create a new ASP.NET Core app and host your Angular app under that one.
-
0
Hello i followed this tutrial and token is now sent on header from angualr to backend https://www.c-sharpcorner.com/article/preventing-csrf-attacks-using-asp-net-core-javascript-and-angular/ the issue now i'm gettgin exception
INFO 2023-04-03 13:02:15,539 [13 ] idateAntiforgeryTokenAuthorizationFilter - Antiforgery token validation failed. The required antiforgery cookie "XSRF-TOKEN" is not present. Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: The required antiforgery cookie "XSRF-TOKEN" is not present. at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery.ValidateRequestAsync(HttpContext httpContext) at Microsoft.AspNetCore.Mvc.ViewFeatures.Filters.ValidateAntiforgeryTokenAuthorizationFilter.OnAuthorizationAsync(AuthorizationFilterContext context)
please help, if you can include refrence for soltuion
-
0
Hi,
As you can see, you need to send
XSRF-TOKEN
using cookies as the error message states;The required antiforgery cookie "XSRF-TOKEN" is not present.