C# @Html.AntiForgeryToken-isn';当我用Firebug更改值时,不能正确地使提交的表单无效
形式中的盐和控制器中的盐都是相同的C# @Html.AntiForgeryToken-isn';当我用Firebug更改值时,不能正确地使提交的表单无效,c#,asp.net-mvc-3,C#,Asp.net Mvc 3,形式中的盐和控制器中的盐都是相同的 public class CheckoutController : Controller { [HttpPost] [ValidateAntiForgeryToken(Salt = SecurityHelpers.AntiforgeryTokenSalt)] public ActionResult Index(decimal amount, string currency, string itemDescription, string
public class CheckoutController : Controller
{
[HttpPost]
[ValidateAntiForgeryToken(Salt = SecurityHelpers.AntiforgeryTokenSalt)]
public ActionResult Index(decimal amount, string currency, string itemDescription, string type)
{
//Magic here.
我的印象是,这将阻止用户使用Firebug更改表单中的隐藏值并提交该值。2美元买一台电视
但是,我可以使用Firebug更改值并提交它,并且可以顺利通过
我在这里遗漏了什么?您遗漏了问题的全部要点。它旨在阻止CSRF攻击,而不是用户在自己的站点上更改表单数据。此外,您不应该从表单数据中检索项目的价格,除非您打算允许客户提供该价格 您错过了整个过程的要点。它旨在阻止CSRF攻击,而不是用户在自己的站点上更改表单数据。此外,您不应该从表单数据中检索项目的价格,除非您打算允许客户提供该价格 看来我完全误解了这是怎么回事。谢谢分享!看来我完全误解了这是怎么回事。谢谢分享!
public class CheckoutController : Controller
{
[HttpPost]
[ValidateAntiForgeryToken(Salt = SecurityHelpers.AntiforgeryTokenSalt)]
public ActionResult Index(decimal amount, string currency, string itemDescription, string type)
{
//Magic here.
public static class SecurityHelpers
{
public const string AntiforgeryTokenSalt = "tokenFooYouTolkienBladeRunner";
}