We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f4c80ca commit bc009fcCopy full SHA for bc009fc
src/Mvc/Mvc.Razor/src/RazorPageBase.cs
@@ -644,9 +644,11 @@ public virtual async Task<HtmlString> FlushAsync()
644
public virtual HtmlString SetAntiforgeryCookieAndHeader()
645
{
646
var viewContext = ViewContext;
647
- var antiforgery = viewContext?.HttpContext.RequestServices.GetRequiredService<IAntiforgery>();
648
- antiforgery.SetCookieTokenAndHeader(viewContext?.HttpContext);
649
-
+ if (viewContext != null)
+ {
+ var antiforgery = viewContext.HttpContext.RequestServices.GetRequiredService<IAntiforgery>();
650
+ antiforgery.SetCookieTokenAndHeader(viewContext.HttpContext);
651
+ }
652
return HtmlString.Empty;
653
}
654
0 commit comments