Return View from ActionFilter

后端 未结 3 823
Happy的楠姐
Happy的楠姐 2020-12-16 11:37

I have an ActionFilter that checks if a parameter in the URL is valid. If it is not valid I have to render a View. I dont want to redirect, because I still need the ActionEx

3条回答
  •  無奈伤痛
    2020-12-16 12:36

    HandleErrorAttribute had what I was looking for.

    filterContext.Result = new ViewResult
                {
                    ViewName = "MessagePage",
                    ViewData = filterContext.Controller.ViewData,
                    TempData = filterContext.Controller.TempData
                };
    

提交回复
热议问题