この場合は、アクション フィルターを使用します。
アクション メソッドの実行をラップするアクション フィルター。このフィルターは、追加のデータをアクション メソッドに提供する、戻り値を検査する、またはアクション メソッドの実行をキャンセルするなど、追加の処理を実行できます。
ここに素敵な MSDN のハウツーがあります:ハウツー: カスタム アクション フィルターを作成する
あなたの場合、次のようなものがあります。
public class RedirectFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (MyService.IsCat==false)
return RedirectToAnotherControllerAction();
}
}
次に、このフィルターをコントローラー レベルで適用します (すべてのコントローラー アクションに適用します)。
[RedirectFilterAttribute]
public class MyController : Controller
{
// Will apply the filter to all actions inside this controller.
public ActionResult MyCatAction()
{
}
}
またはアクションごと:
[RedirectFilterAttribute]
public ActionResult MyCatAction()
{
// Action logic
...
}