diff --git a/src/Microsoft.AspNetCore.Antiforgery/AntiforgeryOptions.cs b/src/Microsoft.AspNetCore.Antiforgery/AntiforgeryOptions.cs
index e59b6aecd9..2c05e1dc1c 100644
--- a/src/Microsoft.AspNetCore.Antiforgery/AntiforgeryOptions.cs
+++ b/src/Microsoft.AspNetCore.Antiforgery/AntiforgeryOptions.cs
@@ -16,11 +16,17 @@ namespace Microsoft.AspNetCore.Antiforgery
private string _cookieName;
private string _formFieldName = AntiforgeryTokenFieldName;
+ ///
+ /// The default cookie prefix, which is ".AspNetCore.Antiforgery.".
+ ///
+ public static readonly string DefaultCookiePrefix = ".AspNetCore.Antiforgery.";
+
///
/// Specifies the name of the cookie that is used by the antiforgery system.
///
///
- /// If an explicit name is not provided, the system will automatically generate a name.
+ /// If an explicit name is not provided, the system will automatically generate a
+ /// unique name that begins with .
///
public string CookieName
{
diff --git a/src/Microsoft.AspNetCore.Antiforgery/Internal/AntiforgeryOptionsSetup.cs b/src/Microsoft.AspNetCore.Antiforgery/Internal/AntiforgeryOptionsSetup.cs
index f1f7dc612a..1c5a3fa4b8 100644
--- a/src/Microsoft.AspNetCore.Antiforgery/Internal/AntiforgeryOptionsSetup.cs
+++ b/src/Microsoft.AspNetCore.Antiforgery/Internal/AntiforgeryOptionsSetup.cs
@@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Antiforgery.Internal
if (options.CookieName == null)
{
var applicationId = dataProtectionOptions.ApplicationDiscriminator ?? string.Empty;
- options.CookieName = ComputeCookieName(applicationId);
+ options.CookieName = AntiforgeryOptions.DefaultCookiePrefix + ComputeCookieName(applicationId);
}
}
diff --git a/test/Microsoft.AspNetCore.Antiforgery.Test/Internal/AntiforgeryOptionsSetupTest.cs b/test/Microsoft.AspNetCore.Antiforgery.Test/Internal/AntiforgeryOptionsSetupTest.cs
index a981339793..79804b4117 100644
--- a/test/Microsoft.AspNetCore.Antiforgery.Test/Internal/AntiforgeryOptionsSetupTest.cs
+++ b/test/Microsoft.AspNetCore.Antiforgery.Test/Internal/AntiforgeryOptionsSetupTest.cs
@@ -10,8 +10,8 @@ namespace Microsoft.AspNetCore.Antiforgery.Internal
public class AntiforgeryOptionsSetupTest
{
[Theory]
- [InlineData("HelloWorldApp", "tGmK82_ckDw")]
- [InlineData("TodoCalendar", "7mK1hBEBwYs")]
+ [InlineData("HelloWorldApp", ".AspNetCore.Antiforgery.tGmK82_ckDw")]
+ [InlineData("TodoCalendar", ".AspNetCore.Antiforgery.7mK1hBEBwYs")]
public void AntiforgeryOptionsSetup_SetsDefaultCookieName_BasedOnApplicationId(
string applicationId,
string expectedCookieName)