Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

ASP.NET MVC Introduction:-
......................................................................................................................................................................

it is used to create a dynamic web application using the MVC Design patterns.

MVC means Model, View, and Controller

Model ----> Data Access Layer

View ----> Designing

Controller ---> logic

MVC Provide distributed project structure for a large web application.

it provides better performance and security as compared to ASP.NET Classic Web Application. ASP.NET Classic has server-side controls which take more time to process data.

Install visual studio,

File ----- >  New ----> Project---> Select Web from Left Side bar ----->  ASP.NET MVC4 Web Application ---->  Empty


Step1st:-

Create Controller


 public class HelloController : Controller
    {
        //
        // GET: /Hello/

        public ActionResult Index()
        {
            return View();
        }

    }

Step2nd:-

Create View:-

Right-click on the controller method and select add view menu option then it will create html file
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
</head>
<body>
    <div>
        <h1>Welcome in ASP.NET MVC Web Application</h1>
    </div>
</body>
</html>


Step3rd:-


APP_Start->RouteConfig.Cs--> Controllername ---> Methodname
  routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );



Now I am providing another example to create an Addition Program then.


1)  create controller under right-click on controller folder.

public class AdditionController : Controller
    {
        //
        // GET: /Addition/

        public ActionResult Index()
        {
            int a = 100, b = 200, c;
            c=a+b;
            ViewBag.data = "Result is " + c;
            return View();
        }

    }

2)  create view and write viewdatta object

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
</head>
<body>
    <div>
        @ViewBag.data
    </div>
</body>
</html>







Post a Comment

POST Answer of Questions and ASK to Doubt

Previous Post Next Post