I have an HTMl app, which uses Web API and AngularJS. We are planing to implement AntiForgery token in the App. I have an Index.cshtml page in which I have added these code
@using System.Web.Helpers
@functions{
public string GetAntiForgeryToken()
{
string cookieToken, formToken;
AntiForgery.GetTokens(null, out cookieToken, out formToken);
return cookieToken + ":" + formToken;
}
}
And added an input tag like this:
<input id="antiForgeryToken" data-ng-model="antiForgeryToken" type="hidden"
data-ng-init="antiForgeryToken='@GetAntiForgeryToken()'" />
When I run the app, I am getting this error:
Error Message: CS0117: 'System.Web.Helpers.AntiForgery' does not contain a definition for 'GetTokens'
ref : Web API and ValidateAntiForgeryToken
Can anyone advice?
What am I missing? Or is there a better way to implement Antiforgery token validation?