17 April 2014

Action Methods -- MVC Basics

User gives request to the controller via URL. And the Controller processes the requests using the action methods defined by the Controller.

For an instance the given below is the Home Controller for a new project. 

Index and about are the action method of Home Controller

Using system;
Using System.Collections.Generic;
Using System.Linq;
Using System.web;
Using System.web. MVC;
Namespace MVCApplication.Controllers
{
  Public Class HomeController: Controller
  {
      Public actionResult Index ()
      {

        ViewBag.Message=”Welcome to ASP.net”; 
        Return View ();
       }
   }

Public actionResult about ()
{
Return view ();
}
}
}

No comments:

Post a Comment