4

I have C# n-layer application. Normaly we use Forms authentication and everything works fine, but when we tried to set authentication on Windows, it started to throw following exception in some occassions (mostly in administration, for exaple when you try edit user and client calls server for user details) This isn't happening in Internet Explorer at all. In Firefox and Chrome it throws it every time.

System.Web.HttpException (0x80004005): 
Server cannot set status after HTTP headers have been sent.
at System.Web.HttpResponse.set_StatusCode(Int32 value)
at System.Web.HttpResponseWrapper.set_StatusCode(Int32 value)
at System.Web.Mvc.HttpStatusCodeResult.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)

Please, can you give me some advice what could possibly go wrong and how to fix it? Thanks

1 Answers1

0

Well, you have to look at your code and see where things are being written to the output stream. What's happening is something is writing out something before you set the status code, and ASP.NET won't allow that.

As for why it happens on FF and Chrome, do you have any code that tries to identify which browser it is and send different things to different browsers?

Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291
  • Yes did that and saw nothing that could cause that error, it was first what I did. I'm thinking, if there was something wrong shouldn't it be wrong even if authentication is set to Forms? And no, i do different thing to different browsers only in javascript UI. – user1728989 Oct 09 '12 at 13:22