Built-in base class for controllers in ASP.NET MVC: controller or controller?

What is the built-in base class for controllers in ASP.NET MVC:

System.Web.Mvc.Controller or System.Web.Mvc.ControllerBase?

I don’t understand after searching on Google:

  • In www.ASP.NET : "The controller is a class that derives from the base class System.Web.Mvc.Controller."

  • In codeproject : "The abstract ControllerBase class represents the base class for all MVC controllers."

  • On MSDN: "The base class for all controllers is the ControllerBase class, which provides general MVC processing. The Controller class inherits from ControllerBase and is the standard execution of the controller."

  • In the book "About ASP.NET MVC 5 Framework" by Adam Freeman: "In ASP.NET MVC, controllers are only C # classes (usually inherited from System.Web.Mvc.Controller, in the base class of the controller).

Who is right? What does “embedded base class” mean in this context? Is the "Controller" the built-in base class and the "ControllerBase"? (what would be the correct wording?) of the base class?

0
source share
3 answers

Controlleris a class that you should use to implement your own MVC controllers. ControllerBaseis inferred Controllerand, like any abstract class, does not provide implementations to some members that Controllerit does.

, Controller , ControllerBase (, View() , , !).

, ControllerBase - , .

+4

ASP MVC , IController. Controller ControllerBase.

, IController .

ControllerBase IController (, ViewBag). ExecuteCore, . ControllerBase, .

Controller ControllerBase. ExecuteCore , (, View(), Redirect() ..).

- ControllerBase, Controller . , ASP.NET MVC. , , , .

+1

Controller class - ControllerBase, , HTTP-.

ControllerBase , , . IController, Execute. , : .

Controller, ControllerBase .

0

Source: https://habr.com/ru/post/1682171/


All Articles