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
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论