{"action":"created","issue":{"url":"https://api.github.com/repos/KentorIT/owin-cookie-saver/issues/6","labels_url":"https://api.github.com/repos/KentorIT/owin-cookie-saver/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/KentorIT/owin-cookie-saver/issues/6/comments","events_url":"https://api.github.com/repos/KentorIT/owin-cookie-saver/issues/6/events","html_url":"https://github.com/KentorIT/owin-cookie-saver/issues/6","id":109104817,"number":6,"title":"\"Server cannot modify cookies after HTTP headers have been sent\" error with SignalR","user":{"login":"tlmii","id":9613109,"avatar_url":"https://avatars.githubusercontent.com/u/9613109?v=3","gravatar_id":"","url":"https://api.github.com/users/tlmii","html_url":"https://github.com/tlmii","followers_url":"https://api.github.com/users/tlmii/followers","following_url":"https://api.github.com/users/tlmii/following{/other_user}","gists_url":"https://api.github.com/users/tlmii/gists{/gist_id}","starred_url":"https://api.github.com/users/tlmii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tlmii/subscriptions","organizations_url":"https://api.github.com/users/tlmii/orgs","repos_url":"https://api.github.com/users/tlmii/repos","events_url":"https://api.github.com/users/tlmii/events{/privacy}","received_events_url":"https://api.github.com/users/tlmii/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-30T14:33:19Z","updated_at":"2015-09-30T19:17:50Z","closed_at":null,"body":"I am getting the following error:\r\n\r\n    System.Web.HttpException (0x80004005): Server cannot modify cookies after HTTP headers have been sent.\r\n       at System.Web.HttpResponse.BeforeCookieCollectionChange()\r\n       at Kentor.OwinCookieSaver.KentorOwinCookieSaverMiddleware.<Invoke>d__0.MoveNext()\r\n    --- End of stack trace from previous location where exception was thrown ---\r\n       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n       at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.<RunApp>d__5.MoveNext()\r\n    --- End of stack trace from previous location where exception was thrown ---\r\n       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n       at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.<DoFinalWork>d__2.MoveNext()\r\n    --- End of stack trace from previous location where exception was thrown ---\r\n       at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar)\r\n       at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar)\r\n       at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()\r\n       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)\r\n\r\n**only** on calls to SignalR's ping handler (/signalr/ping?_=[ timestamp ]). All other calls seem to work fine.\r\n\r\nI thought it might be related to this pull request: https://github.com/KentorIT/owin-cookie-saver/pull/5 so I upgraded to the 1.1 release and changed my code to use the new extension method. Now I've got:\r\n\r\n    public partial class Startup\r\n    {\r\n        public void ConfigureAuth(IAppBuilder app)\r\n        {\r\n            var options = new CookieAuthenticationOptions();\r\n            ...\r\n            app.UseKentorOwinCookieSaver(PipelineStage.Authenticate);\r\n            app.UseCookieAuthentication(options);\r\n            app.UseWsFederationAuthentication( ... );\r\n        }\r\n    }\r\n\r\nBut it did not make a difference. Do I need to use something other than Authenticate for the PipelineStage? Or is something else going on here?"},"comment":{"url":"https://api.github.com/repos/KentorIT/owin-cookie-saver/issues/comments/144511708","html_url":"https://github.com/KentorIT/owin-cookie-saver/issues/6#issuecomment-144511708","issue_url":"https://api.github.com/repos/KentorIT/owin-cookie-saver/issues/6","id":144511708,"user":{"login":"tlmii","id":9613109,"avatar_url":"https://avatars.githubusercontent.com/u/9613109?v=3","gravatar_id":"","url":"https://api.github.com/users/tlmii","html_url":"https://github.com/tlmii","followers_url":"https://api.github.com/users/tlmii/followers","following_url":"https://api.github.com/users/tlmii/following{/other_user}","gists_url":"https://api.github.com/users/tlmii/gists{/gist_id}","starred_url":"https://api.github.com/users/tlmii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tlmii/subscriptions","organizations_url":"https://api.github.com/users/tlmii/orgs","repos_url":"https://api.github.com/users/tlmii/repos","events_url":"https://api.github.com/users/tlmii/events{/privacy}","received_events_url":"https://api.github.com/users/tlmii/received_events","type":"User","site_admin":false},"created_at":"2015-09-30T19:17:50Z","updated_at":"2015-09-30T19:17:50Z","body":"I had someone else on my team check one of their projects (almost all of ours use the Owin Cookie Saver - thanks for your work! - but only a few have SignalR too). He was seeing the same thing. The interesting thing is it only seems to happen with the /signalr/ping calls that appear to only happen if the page is left open for an hour or more. So its not an easy thing to reproduce! Hoping @jaymclain or someone else can at least point me in the right direction. Thanks!"}}