Create an ASP.NET MVC 2 empty application. Add a controller named HomeController and write the following action method.
public ViewResult Index() { return View(); }
ActionResult Class:
All methods within a controller are Action methods, and returns ActionResult object.
The above function returns ViewResult
object; which is a subclass of ActionResult
Adding View:
Right click in the method and select add view option. Name the View as "Index" and add the view.
Run the application. Hence you have created an MVC application which returns a View.
No comments:
Post a Comment