Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# @Html.AntiForgeryToken-isn';当我用Firebug更改值时,不能正确地使提交的表单无效_C#_Asp.net Mvc 3 - Fatal编程技术网

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";
}