[RESOLVED]may be controller internal or not

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.

  1. Controller class should be marked with public
  2. Should always ends with Controller
  3. Its not abstract
  4. 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.


Leave a Reply