Posts

Explain terms of MVC ?

  MVC is Model, View, Controller.       1) Model :-  Model represents data and business logic. it maintains the data of the application.                        we can create an object of the model and using that object we can store                       and retrieve data from the database        2) View :- View is User interface means UI.                    View Display data using a model to users and enable them to modify data.    3) Controller :- Controller is a request handler.  The controller handles user requests.                              a user interacts with the view. The controller renders View with                              model data as a response.                     

Action method in MVC

Image
                                Action Method in MVC          1)  When we create a controller in MVC it creates Default method Index which is called as                 Action method             2)  When you create a method in controller every method is public. means every action method                is public           3)  When we create an Action method we can not create a method as static.             4)  When we hit URL from the browser then it performs the MVC life cycle and finds a                controller and action method in return response to the user.           Let Understand How to create Action method in Controller                            The first   step to creating a project  in MVC   . after creating a project  right click on the controller        Add Controller and inside a controller, we can add multiple action method.               please choose controller and give controller name so when we create controller it creates     default method which is index method   

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

Routing in Asp.Net MVC with example

                       Routing in Asp.Net MVC with example           Routing is defined in the RegisterRoutes method inside the RouteConfig class.         this RouteConfig class resides in App_Start Folder.                public static void RegisterRoutes(RouteCollection routes)         {             routes.IgnoreRoute("{resource}.axd/{*pathInfo}");             routes.MapRoute(                 name: "Default",                 url: "{controller}/{action}/{id}",                 defaults: new { controller = "Account", action = "Index", id = UrlParameter.Optional }             );                     }         Routing is a pattern matching system . when any user request from the browser at runtime          Routing engine use routing table for matching user request URL pattern against the URL          a pattern that is defined in the Route table.  You can register one or more URL         patterns in the route table but name is require diffe

ASP.NET MVC Architecture

Image
                             ASP.NET MVC Architecture  MVC is Model, View, and controller. it separates an application into three-part     1)Model 2) View 3) Controller.  Let understand each part in details below:-  1)  Model :-  Model represents data and business logic. it maintains the data of the application.                        we can create an object of the model and using that object we can store                        and retrieve data from the database        2)  View :- View is User interface means UI.                     View Display data using a model to users and enable them to modify data.    3)  Controller :- Controller is a request handler.  The controller handles user requests.                              a user interacts with the view. The controller renders View with                               model data as a response.                                                                    

ASP.NET MVC Folder Structure

Image
                            ASP.NET MVC Folder Structure                                Hello, you will learn the folder structure of MVC . when we create a new MVC application it creates a default structure below:-                  Let Understand Folder                              1) App_Data :- This folder contains files like .mdf file  , XML file , localdb etc.               2) App_Start:- This folder contains files like a bundle.config.cs, filter.config.cs ,                                          RouteConfig.cs . this three file in MVC 5  include by default.                                          this file executed when application_start called from global.asax                                                        3) Content:-      This folder contains  CSS file ,image ,icon . by default bootstrap.cs,                                          bootstrap.min.cs, site.css are added in MVC5.             4) Controllers:- This folder contains class files and this class file inherit

How To Create an MVC application in Visual Studio 2019

Image
                                     Below is a step to create an MVC project.    1) First, need visual studio so before creating MVC application first install Visual studio        https://visualstudio.microsoft.com/downloads/    you can install the latest version from the above URL.  2) Open Visual Studio 2019 and click on create a new project.       3)  After creating a new project. it showing multiple templates. you can choose any template       based on your requirement.                     1) Search ASP.NET in search box        2) Find ASP.NET Web application. if you want to develop an application in VB(visual basic)            then select VB  template if you want to develop an application in C#            then select the C# template.      3) Click on Next.           4) Above image for configuring your new project          1) Project Name :- you can give any name.         2) Location:- You can give any location to the store the project.         3) click on Create.