开发者

Whats in the base class of ActionFilterAttribute?

I am making an action filter to do a check and see if a user still has a valid key. I am just wondering what is in the base.OnActionExecuting(filterContext);?

Like do I nee开发者_StackOverflow社区d to call it?

Also where can I download the source for mvc 2.0? I know you could do it with 1.0 but I forgot where the files are.


Chobo2, you would only call the base if there are other actions, within the frame work, that might impact on the outcome of your method.

Take this;

    public bool Overide { get; set; }

    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        if (!this.Overide)
        {
            filterContext.Result = new RedirectResult("/Home/Index");
        }
    }

Clearly this code does not need to call base as all the code required to make the decision is contained within my method. If however, I was to set something in the framework that might affect execution then I'd call the base and let it decide.

I think the 90/10 rule would be that you wouldn't call base.

As for MVC 2 download

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜