Computer Magic Logo
form

Wednesday, March 22, 2017

Published by Aristotelis Pitaridis

The following example demonstrates how to use the form tag helper to create a form for our web site.

<form asp-controller="Home" asp-action="Index">
    <input class="btn btn-success" type="submit" />
</form>

The above code will generate the following HTML.

<form action="/" method="post">
    <input class="btn btn-success" type="submit" />
    <input name="__RequestVerificationToken" type="hidden" value="CfDJ8Cc6bJ3TWmVAoCQJZSt8GLsH1Kd1vwhvwdraLv9RMk1g19PWdA61QERowGKewI5L-1rx6CgL6FEnP2ceO1Pg0ztoCjBBFVl7FtPiUSNNvcRc7V8Rfjjvro-A0K7ngCkTYHNYlU-oJJ7vg-FakXriagE" />
</form>

As we can see the form tag helper generates the __RequestVerificationToken input which will be used as anti-forgery token.