My first ASP.Net MVC Program

In all my blog I will be giving example/code in context of Visual Studio 2015.
So first create a MVC project in VS 2015.

File-> New -> Project
Select Web from templates (from left side) and ASP.Net Web Application from middle section, click on OK.

Now select MVC from template section and click on ok. Your MVC project will be created.

You may see some folders in solution explorer with name Models, Views, Controllers

To create MVC project in VS 2015, follow below steps.








For eg I have a controller with name "HomeController.cs" which is in Controllers folder cpntaining below piece of code.

public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }

 Now lets start discussion on HomeController , then we will come to code section.
HomeController is the name of class and Home is the name of controller. When you want to hit controller from url just ignore the word Controller.

For eg You have a controller called "HomeController"
You may hit like this.

http://localhost:1000/Home

Now come to coding section, what is Action method.
Action method is a public method available within controller which returns response based on request.

Comments

Popular

Top 8 C# 6.0 Features

SharePoint Interview Questions and Answers

Calling ASP.Net WebMethod using jQuery AJAX

What is Cloud Computing - A guide for beginners