开发者

Setting Response.StatusCode in View in ASP.NET MVC2

开发者 https://www.devze.com 2023-01-03 00:39 出处:网络
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:

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 bee开发者_JAVA技巧n sent.

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


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消