English 中文(简体)
如果在一页中增加多种表格,我是否需要增加每种形式的反宗教基金。
原标题:If I add multiple forms in a single page, do I need to add separate Anti-Forgery Tokens in each form?

如果答案是肯定的,那么伙伴关系将如何。 NET MVC发现,哪一个被点与哪一种形式有关,以及如何加以验证?

我看到,它正在为每一种形式设立两个单独的标语。

最佳回答

在这个问题上,你不需要做什么。 ASP. NET MVC将只是重复使用所有形式相同的价值,因此,它不需要知道发出这一请求的哪一种形式才能验证。 Simply put an Html.AntiForgery Token ( in each form and decorate each controller actions You are posting to with the [ValidateAntiForgery Token] 属性, 您应为OK.

问题回答

There is a great article here I pointed out some important sections.

In a nutshell, If a token can be deserialized from the request’s cookie collection, it’ll reuse that token instead of generating a new one. If a token doesn’t exist in the cookie collection, it’ll instantiate a new instance of “AntiForgeryToken” and randomly generate a new 16 byte array to represent the token.

public AntiForgeryToken GetCookieToken(HttpContextBase httpContext)
{
    HttpCookie cookie = httpContext.Request.Cookies[this._config.CookieName];

    if (cookie == null || string.IsNullOrEmpty(cookie.Value))
        return (AntiForgeryToken) null;

    return this._serializer.Deserialize(cookie.Value);
}

“Html.AntiForgery Token()”这一助手方法之后,将采用同样的步骤,利用现有的 co子()而不是产生新的价值。

www.un.org/Depts/DGACM/index_spanish.htm 既然这是一门 session子,这意味着反org灵的面具的价值仅在浏览器会议期间产生一次,再用于随后的所有电话。

www.un.org/Depts/DGACM/index_spanish.htm 因此,如果隐蔽的实地价值被重新使用,那么这种价值是不同的?

因此,尽管加密价值可能有所不同,但加密价值却相同。

byte[] one = MachineKey45CryptoSystem.Instance.Unprotect("iAdQj5D0qrMuTggD8WpnOZPlVOfHg_qmPIEjnULAYd1h56cV2cL51rcaY8_UgxQbav5_6KTAtyE52ir1X6GmaS9ZPgw1");
byte[] two  = MachineKey45CryptoSystem.Instance.Unprotect("Shvi8Bxe6-a8zfCfDGnxkaC-IETsbjkR9iIylwn-2VRWQ-GtQkdowdFw1biU7dN3j-xPJZHYQPe-hNfWspYjy_ZcCCY1");
byte[] three = MachineKey45CryptoSystem.Instance.Unprotect("ZhaVFngUMLo88jmTIx___BTWlYFyKh1GalwEeffRl0-o3Gu7_m98k6aQjO7IysZIdXxVx6TqL6QIfX19Uwq3Ia6dghA1");

相比之下,所有三个星体阵列的分布情况相同。





相关问题
WebForms and ASP.NET MVC co-existence

I am trying to make a WebForms project and ASP.NET MVC per this question. One of the things I ve done to make that happen is that I added a namespaces node to the WebForms web.config: <pages ...

Post back complex object from client side

I m using ASP.NET MVC and Entity Framework. I m going to pass a complex entity to the client side and allow the user to modify it, and post it back to the controller. But I don t know how to do that ...

Create an incremental placeholder in NHaml

What I want to reach is a way to add a script and style placeholder in my master. They will include my initial site.css and jquery.js files. Each haml page or partial can then add their own required ...

asp.net mvc automapper parsing

let s say we have something like this public class Person { public string Name {get; set;} public Country Country {get; set;} } public class PersonViewModel { public Person Person {get; ...

structureMap mocks stub help

I have an BLL that does validation on user input then inserts a parent(PorEO) and then inserts children(PorBoxEO). So there are two calls to the same InsertJCDC. One like this=>InsertJCDC(fakePor)...

ASP.NET MVC: How should it work with subversion?

So, I have an asp.net mvc app that is being worked on by multiple developers in differing capacities. This is our first time working on a mvc app and my first time working with .NET. Our app does not ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

热门标签