1

我有一个带有以下代码的 MVC 3 视图:-

@using (Html.BeginForm(MVC.Order.SearchResults(), FormMethod.Get))
{
    @Html.AntiForgeryToken()

    @Html.Button("btnSearch", "Search", HtmlButtonType.Submit, null, new { @class = "button primary icon search", alt = "Search the orders (up to 50 characters)" }
}

当我发布表单时,我看到 __RequestVerificationToken= 和查询字符串中的验证令牌的内容。

任何想法为什么会出现这种情况以及如何对其进行排序?

4

2 回答 2

4

防伪令牌仅适用于 POST 请求。如果您想使用它们,您需要将表单中使用的动词更改为 POST 而不是 GET:

@using (Html.BeginForm(MVC.Order.SearchResults(), FormMethod.Post))
{
    @Html.AntiForgeryToken()

    @Html.Button("btnSearch", "Search", HtmlButtonType.Submit, null, new { @class = "button primary icon search", alt = "Search the orders (up to 50 characters)" }
}
于 2011-12-12T11:57:43.563 回答
0

有一种解决方法,您可以通过 GET 方法甚至在标头中传递 antiforegy 值。更多细节在这里

于 2011-12-13T11:37:52.427 回答