("Password", "password"),
+ };
+
+ request.Content = new FormUrlEncodedContent(nameValueCollection);
+
+ // Act
+ var response = await client.SendAsync(request);
+
+ // Assert - 2
+ var exception = response.GetServerException();
+ Assert.Equal("The required anti-forgery cookie \"__RequestVerificationToken\" is not present.",
+ exception.ExceptionMessage);
+ }
+
}
}
\ No newline at end of file
diff --git a/test/WebSites/AntiForgeryWebSite/Controllers/AccountController.cs b/test/WebSites/AntiForgeryWebSite/Controllers/AccountController.cs
index 701b421a39..1a32e742c5 100644
--- a/test/WebSites/AntiForgeryWebSite/Controllers/AccountController.cs
+++ b/test/WebSites/AntiForgeryWebSite/Controllers/AccountController.cs
@@ -31,5 +31,41 @@ namespace AntiForgeryWebSite
{
return "OK";
}
+
+ // GET: /Account/FlushAsyncLogin
+ [AllowAnonymous]
+ public ActionResult FlushAsyncLogin(string returnUrl = null)
+ {
+ ViewBag.ReturnUrl = returnUrl;
+
+ return View();
+ }
+
+ // POST: /Account/FlushAsyncLogin
+ [HttpPost]
+ [AllowAnonymous]
+ [ValidateAntiForgeryToken]
+ public string FlushAsyncLogin(LoginViewModel model)
+ {
+ return "OK";
+ }
+
+ // GET: /Account/FlushWithoutUpdatingHeader
+ [AllowAnonymous]
+ public ActionResult FlushWithoutUpdatingHeader(string returnUrl = null)
+ {
+ ViewBag.ReturnUrl = returnUrl;
+
+ return View();
+ }
+
+ // POST: /Account/FlushWithoutUpdatingHeader
+ [HttpPost]
+ [AllowAnonymous]
+ [ValidateAntiForgeryToken]
+ public string FlushWithoutUpdatingHeader(LoginViewModel model)
+ {
+ return "OK";
+ }
}
}
\ No newline at end of file
diff --git a/test/WebSites/AntiForgeryWebSite/Views/Account/FlushAsyncLogin.cshtml b/test/WebSites/AntiForgeryWebSite/Views/Account/FlushAsyncLogin.cshtml
new file mode 100644
index 0000000000..65ee7aedd1
--- /dev/null
+++ b/test/WebSites/AntiForgeryWebSite/Views/Account/FlushAsyncLogin.cshtml
@@ -0,0 +1,43 @@
+@model AntiForgeryWebSite.LoginViewModel
+
+@{
+ ViewBag.Title = "Log in";
+ Layout = "/Views/Shared/_FlushAsyncLayout.cshtml";
+}
+
+@section Login
+{
+@ViewBag.Title.
+
+}
diff --git a/test/WebSites/AntiForgeryWebSite/Views/Account/FlushWithoutUpdatingHeader.cshtml b/test/WebSites/AntiForgeryWebSite/Views/Account/FlushWithoutUpdatingHeader.cshtml
new file mode 100644
index 0000000000..97cf95a94e
--- /dev/null
+++ b/test/WebSites/AntiForgeryWebSite/Views/Account/FlushWithoutUpdatingHeader.cshtml
@@ -0,0 +1,37 @@
+@model AntiForgeryWebSite.LoginViewModel
+
+@await FlushAsync()
+
+@ViewBag.Title.
+
diff --git a/test/WebSites/AntiForgeryWebSite/Views/Shared/_FlushAsyncLayout.cshtml b/test/WebSites/AntiForgeryWebSite/Views/Shared/_FlushAsyncLayout.cshtml
new file mode 100644
index 0000000000..08c9240c47
--- /dev/null
+++ b/test/WebSites/AntiForgeryWebSite/Views/Shared/_FlushAsyncLayout.cshtml
@@ -0,0 +1,15 @@
+
+
+ @ViewBag.Title – AntiForgery Functional Tests
+
+@SetAntiForgeryCookieAndHeader()
+@await FlushAsync()
+
+
+ @Html.ActionLink("Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })
+
+ @RenderBody()
+ @await RenderSectionAsync("Login", required: false)
+
+
+
\ No newline at end of file