Posts

Showing posts from August, 2020

ActionResult Return Type in MVC

                                ActionResult Return Type                   When we create an Action method in the controller so ActionResult  is the return type of                    method                        public class LearnController: Controller                     {                        // GET: Learn                         public ActionResult Index()                         {                             ViewBag.Title = "Learn Controller";                              return View();                           }                       }                      above we can see the index method in which return type is ActionResult.                      that means all action methods are derived from ActionResult class.                      so ActionResult  is base class for all action method                  Types of Action Result                  1)  ViewResult:-                      When we use ViewResult in the method then method responsibility is to render             

Controller in MVC

Image
                                                         Controller in MVC           1)  The controller handles user requests. so when a user hit any URL from browser controller                      handle user requests.                               2)   Controller is a class and this controller class derived from the base class               3)    In the controller class, it contains a method which is an action method. so every public                      The action method in the controller class is accessible from a browser.              4)    When we create a new controller it must use the Controller keyword at the end.                     example if we create Home controller you need to give a name like                     HomeController.  so whatever name you can write but at the end must use                     Controller keyword.            5)    When we create multiple controllers with a different name so all multiple controllers                    are store in the Controller