开发者

Define cookies in base call controller

开发者 https://www.devze.com 2023-01-19 22:00 出处:网络
I have two controllers: parent controller inherits from Controller. public class ApplicationController : Controller

I have two controllers:

  1. parent controller inherits from Controller.

    public class ApplicationController : Controller
    {
        public ApplicationController()
        {
        }
    }
    
  2. child controller inherits form above mentioned class.

    public class LayoutCont开发者_如何学运维roller : ApplicationController
    {
        public ActionResult Index()
        {
        }
    }
    

and have Initialize method in parent controller.

protected override void Initialize(System.Web.Routing.RequestContext requestContext)
{
}

and my question is that when "Initialize" method called then action is not call.


Make sure that you call the base method in Initialize:

protected override void Initialize(RequestContext requestContext)
{
    base.Initialize(requestContext);
}

And that you don't have an Index action in the base controller as you already do in the child controller.

I've just tried your sample code and it worked as expected.

0

精彩评论

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