7

をオーバーライドできる以前のHtmlHelper.AntiForgeryTokenstring pathメソッドは非推奨です。

[ObsoleteAttribute("This method is deprecated. Use the AntiForgeryToken() method instead. To specify a custom domain for the generated cookie, use the <httpCookies> configuration element. To specify custom data to be embedded within the token, use the static AntiForgeryConfig.AdditionalDataProvider property.", 
    true)]
public MvcHtmlString AntiForgeryToken(
    string salt,
    string domain,
    string path
)

を使用するように指示します<httpCookies>。ただし、 httpCookies要素には PATH の設定がありません。

これは、このメソッドの非推奨の見落としですか? この Cookie パスを上書きする最良の方法は何ですか? (手動で?) 仮想アプリケーションで Web サイトを実行しても、__RequestVeririfcation Cookie にアプリケーション パスが暗黙的に追加されるわけではありません。

4

3 に答える 3

2

ASP.NET Core の場合 - 参照: AntiforgeryOptions クラス

Cookie - 偽造防止 Cookie の作成に使用される設定を決定します。

例 ( ASP.NET Core での Cross-Site Request Forgery (XSRF/CSRF) 攻撃の防止から適応):

services.AddAntiforgery(options => 
{
    options.Cookie.Path = "Path";
});
于 2018-08-21T20:45:13.820 に答える