Spring.net Invalid filter controller for base class controller in MVC

Source: Internet
Author: User

For example, now I have another basecontroller. As a base class controller, for filtering permissions, login judgment and other functions, the other control from the original controller, inherit Basecontroller. Then Basecontroller rewrite the controller in the method onactionexecuting

When we revisit an action under the user controller at this point, the problem is that the server executes the OnActionExecuting method in Basecontroller, and at this point theIU is not created by Spring.net!! is still null

After several tests, it may be that the Basecontroller is the base class, and each instantiation (access to the subclass controller (Usercontroller) actually instantiates a base class internally). Spring.net has no way to gain access to the base class (Basecontroller) that is instantiated with the following subclass (Usercontroller), so IU will be null.

My workaround is as follows

Basecontroller, as a base class controller, must always be used, so set its constructor to static, execute only once, and assign values to IU at the same time, so that IU will always have values.

Spring.net Invalid filter controller for base class controller in MVC

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.