1
在ASP.NET MVC 3控制器生命周期中ControllerContext是否构建?在ASP.NET MVC 3控制器生命周期中,controllerContext是否被构造?
我在控制器的构造函数下面的代码:
if ((Session == null || Session.IsNewSession || Session["SecureAuthHash"] == null) &&
(ValueProvider == null || ValueProvider.GetValue("controller").ToString() != "Account"))
{
RedirectToAction("Login", "Account");
}
而且我得到以下错误:
Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: controllerContext
当可用的controllerContext所以我的代码可以运行?这应该在任何其他代码之前运行,所以我真的不想将它放在每个操作方法中......但我想这可能是唯一的方法。
TIA, 班吉
谢谢 - 这太好了。 – benjy