When I attempt to run the following code:
<form id="__SendAjaxAntiForgery" action="#" method="post"><%= Html.AntiForgeryToken()%></form>
I get the following error
"Server cannot modify cookies after HTTP headers have been sent."
The stack trace reads
at System.Web.HttpResponse.BeforeCookieCollectionChange()
at System.Web.HttpCookieCollection.Set(HttpCookie cookie)
at System.Web.Helpers.AntiXsrf.AntiForgeryWorker.GetFormInputElement(HttpContextBase httpContext)
at System.Web.Helpers.AntiForgery.GetHtml()
at System.Web.Mvc.HtmlHelper.AntiForgeryToken()
at ASP.views_shared_site_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer)
This only happens when I have 2 tabs open and on one of the tabs I logout and then log back in on tab 1(and in doing so I get a new AntiForgeryToken) and then go to tab 2 and refresh.
The exception is occuring when I attempt to get "Html.AntiForgeryToken();"