0

I am new to the .NET MVC and I was trying to implement functions I had in my previous work on WebForms. I want to extend the normal controller, so that I have a preset of functions and/or variables built in and ready for use in any controller. Is that possible or should I use a model every time I need those functions/variables?

1 Answer 1

3

Create a directory Infrastructure in you MVC project,

Add a class called BaseController that inherits from Controller and add your method in this class

Now, all your controller in your Controller directory should inherit from BaseController instead of Controller.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.