【发布时间】:2010-10-05 04:27:21
【问题描述】:
我有一个 ActionFilter 来检查 URL 中的参数是否有效。 如果它无效,我必须渲染一个视图。我不想重定向,因为我仍然需要 ActionExecutingContext。 可以吗?
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
Guid processIdentifier = (Guid)filterContext.RouteData.Values["processIdentifier"];
//if processIdentifier not found render a view with message and some other objects in ViewData
filterContext.Controller.ViewData.ModelState.AddModelError("WrongProcessIdentifier", "The process-id you supplied is not valid");
base.OnActionExecuting(filterContext);
}
【问题讨论】:
标签: asp.net-mvc