Can I use code like this?
internal class HomeController : Controller
Why not try it yourself and see? Internal classes can’t be accessed by other assemblies so if you are putting your controllers in a different assembly from your main site then it definitely won’t work, but if the controllers are in the same assembly it
should be ok.
Answer is no, Controller marked with internal will not work, as there are certain rules around controller definitions.
- Controller class should be marked with public
- Should always ends with Controller
- Its not abstract
- Its derived from Controller or ControllerBase or implement IController
You might want to look into DefaultControllerFactory implementation to see how it creates the instance of a controller class.