Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.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
Asp.net mvc 是否有方法重命名RequestVerificationToken cookie名称?_Asp.net Mvc_Security_Cookies_Antiforgerytoken - Fatal编程技术网

Asp.net mvc 是否有方法重命名RequestVerificationToken cookie名称?

Asp.net mvc 是否有方法重命名RequestVerificationToken cookie名称?,asp.net-mvc,security,cookies,antiforgerytoken,Asp.net Mvc,Security,Cookies,Antiforgerytoken,使用ASP.net MVC v2.0,有没有办法更改\uu RequestVerificationTokencookie的名称?为了隐藏我们的底层技术堆栈,我想将cookie重命名为无法追溯到ASP.NETMVC的名称 更多信息请访问。查看MVC2源代码,我认为不可能更改cookie名称。AntiForgeryData类启动: private const string AntiForgeryTokenFieldName = "__RequestVerificationToken"; 要获取它只

使用ASP.net MVC v2.0,有没有办法更改
\uu RequestVerificationToken
cookie的名称?为了隐藏我们的底层技术堆栈,我想将cookie重命名为无法追溯到ASP.NETMVC的名称


更多信息请访问。

查看MVC2源代码,我认为不可能更改cookie名称。AntiForgeryData类启动:

private const string AntiForgeryTokenFieldName = "__RequestVerificationToken";
要获取它只调用的cookie名称:

string cookieName = AntiForgeryData.GetAntiForgeryTokenName(ViewContext.HttpContext.Request.ApplicationPath);
在HtmlHelper类中。它获取应用程序路径并将其转换为base 64,然后将其附加到uu RequestVerificationToken的末尾,这就是您在查看源代码时看到的内容


如果您真的需要更改名称,我建议您从codeplex下载MVC2源代码,并参考源代码创建自己的html帮助程序和防伪令牌。但是在这样做的过程中,您总是会引入自己的bug…

ASP.NET MVC 3和4允许您通过设置static
AntiForgeryConfig.CookieName
属性来更改cookie名称。 (Msdn参考)


我知道这个问题是专门针对ASP.NET MVC 2提出的,但这个问题仍然会在搜索引擎中为适当的查询(如“ASP.NET MVC AntiForgeryToken cookie name”)返回较高的排名。我想我应该在这里添加这些信息,以避免其他人像我一样对ASP.NET MVC 3+源代码进行反编译。

感谢您提供了如此详细的分析。我想我现在只使用默认名称,不想维护更多的源代码。也许我会向MVC团队提出这个请求。不幸的是,没有等效的方法来更改隐藏的输入名称
\uu RequestVerificationToken