Created
April 30, 2010 14:12
-
-
Save hhariri/385258 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HandleRecordNotFoundAttribute : ActionFilterAttribute | |
{ | |
public override void OnResultExecuting(ResultExecutingContext filterContext) | |
{ | |
var viewResult = filterContext.Result as ViewResult; | |
if (viewResult != null && viewResult.ViewData.Model == null) | |
{ | |
filterContext.Result = new ResourceNotFoundResult(); | |
filterContext.Result.ExecuteResult(filterContext.Controller.ControllerContext); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment