Click here to Skip to main content
15,746,813 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
At Backend, I have used web API and I can validate the token by comparing hidden field token and cookies token as shown below:

  string cookieToken, formToken;
  AntiForgery.GetTokens(null, out cookieToken, out formToken);

  CookieHeaderValue cookie = Request.Headers
  if (cookie != null)
    Stream requestBufferedStream = Request.Content.ReadAsStreamAsync().Result;
    requestBufferedStream.Position = 0;
    NameValueCollection myform = Request.Content.ReadAsFormDataAsync().Result;
    catch (Exception ex)
      throw new HttpResponseException(
       new HttpResponseMessage(HttpStatusCode.Unauthorized));

But the main problem is: I am not able to set csrf token using web API and also the same not able to receive the same csrf token in vue js.

I have a separate project as backend( web API) and frontend (Vue).

What I have tried:

I only know to validate the token as given above.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900