开发者

Do we need to Response.Clear in custom HandleErrorAttribute?

I am reading Pro ASP.NET MVC 2 Framework by Steven Sanderson (Apress) and I see this code for a custom HandleErrorAttribute:

public class RedirectOnErrorAttribute : FilterAttribute, IExceptionFilter 
{ 
    public void OnException(ExceptionContext filterContext) 
    { 
    // do stuff. finally do:
        filterContext.ExceptionHandled = true; 
        filterContext.HttpContext.Response.Clear(); 
    } 
}

Why do we need to Response.Clear() at the end? Thank开发者_运维百科 you.


It removes from the Response any content that might been added by your code before the exception was thrown since very likely it is now useless.

http://msdn.microsoft.com/en-us/library/ms525713(v=vs.90).aspx

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜