How to understand the Concepts of Controller class in MVC Applications

We have usually developed many applications.But didn't discuss this concepts before.In, user interaction is structured in the sequence of web pages and handles the event of those pages.But In ASP.NET MVC ,user interaction is structured around the controller and action methods.Here ,the Action methods usually have a one to one mapping with user interaction.
The controller classes are the classes that are mapped by the ASP.NET MVC framework URLs.Here,you will see,the controller classes process the incoming request ,tackle the user input and interactions and finally execute the appropriate application logic.The base class for all the controller in controller class which perform MVC handling concepts.
A controller class invokes the a separate view component to generate the HTML Markup for any incoming request. The controller class uses the Icontroller , IActionFilter and IDisposable interfaces .

A class which is derived from controller class ,performed following actions as given below.
  1. It is helpful to locate the appropriate action method to call and validate.
  2. It is used to set the values as the action method's arguments.
  3. It is helpful to handling the all errors that occurs during the execution of the action method.
  4. It provide default web form view factory class for loading ASP.NET Page types.        

public class MyfirstController : Controller
        // GET: /Myfirst/

        public ActionResult Index()
            ViewData["title"] = "Welcome to";
            ViewData["Date_Time"] = DateTime.Now.ToString();
            return View();

  • Here simple,I have created a Myfirst controller class .
  • Here In this class, Index () is an Action.
  • Any body calls the Myfirst controller class then it first call Index() function.
  • This Index () Function return a view Object.
  •  After that, this view is translated in ActionResult .
  • After that,this ActionResult will be displayed on the Browser. Which will be visible to every clients.
I will discuss the URL Routing concepts latter.
For More...
  1. How to implement data binding concepts in WPF application
  2. How to implement role based security in application 
  3. Namespaces in WPF Application
  4. How to implement 3tier architure concepts in application
  5. How to implement polymorphism concepts in c#
  6. C# advanced interview questions and answers


Post a Comment

Powered by Blogger.