0

I've just converted a project from MVC1 to MVC2. In the MVC1 project the HTTP status code was being set in some of the views. These views are now generating this exception:

Server cannot set status after HTTP headers have been sent.

What has changed from MVC1 to MVC2 to cause this and is there any way to fix this?

Guy
  • 65,082
  • 97
  • 254
  • 325

1 Answers1

1

I would argue that you shouldn't be setting any status codes in the views at all. Is this not the role of the controller at most?

Matthew Abbott
  • 60,571
  • 9
  • 104
  • 129
  • Generally I would agree with you but this was a case where I was using the view from multiple locations in the Controllers and wanted to apply the DRY principal so I only wanted to set the Status Codes in one location. – Guy Jun 08 '10 at 13:23