0
votes

I'd like to obtain anti-forgery token value in ASP .NET MVC project. I have investigated the HtmlHelper.AntiForgeryToken helper method only to find that it uses the AntiForgery class which provides public method GetHtml used by the aforementioned helper. The problem is this method only returns the HTML of the entire hidden form input field represented by HtmlString. I'd like to get my hand on the name of the field and its value, which I am able to do now parsing the returned HtmlString, but not in any clear way. Everything useful (like IAntiForgeryConfig implementation for the field name) is internal. Is there any other facet of the MVC infrastructure that I am not aware of that offers public members allowing the access to the form field name and value rather that the serialized values?

1

1 Answers

1
votes

Alright, the method I was after was hidden in a plain sight. The AntiForgery class provides a public method called GetTokens which is what I need.