Why does @Html.AntiForgeryToken() generate different tokens in same response?

后端 未结 6 706
一向
一向 2020-12-16 04:32

A single Razor view contains several forms, each with its own call to @Html.AntiForgeryToken()

@Html.AntiForgeryToken
6条回答
  •  醉话见心
    2020-12-16 05:10

    Surely they should be the same, because they are sent in the same Response?

    The Response has nothing to do with it. @Html.AntiForgeryToken() is a static method of HtmlHelper which generates a unique token that is added to the html and the response cookie. Your calling the method multiple times so your generating multiple tokens.

    If it did not generate a unique token each time it would hardly be secure.

提交回复
热议问题