46
Tutorial -01

Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Embed Size (px)

Citation preview

Page 1: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Tutorial -01

Page 2: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Objective

In this session we will discuss about :

1. What is MVC?

2. Why MVC?

3. Advantages of MVC over ASP.NET

4. ASP.NET development models

5. How to Install MVC?

6. MVC Release History   

7. Creating First Asp.Net MVC Application

Page 3: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

What is MVC?

Page 4: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

MVC ?• MVC is successor of ASP.NET So Before going to discuss about MVC lets little bit talk about

Asp.Net.

• It is a part of .NET framework developed by Microsoft.

• It is used to Create Web Application(Internet Application).So that every one can access

this application from anywhere.

• This application will be access thru Web Browser( Firefox, Chrome. Internet Explorer etc)

by passing URL in url bar.

• This application will be stored & execute on server.

Like: www.google.com , www.prognoztech.com , www.amazon.com are internet

application we are accessing thru url.

Page 5: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

MVC (Continue…)

• There are a lot of other programming language( a language that machine

understand) used to create Internet application,

1. Java

2. PHP

3. CGI

4. ASP

Page 6: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Disadvantage of ASP.NET

• There are a lot of code required to create Web(Internet) Application using ASP.NET,

• MVC make it simple by categorize the structure of Asp.Net in 3 parts.

• Lets talk about ASP.NET internet development model in details:

Page 7: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

ASP.NET supports three different development models

Page 8: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Differences between these development models are:

Page 9: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

MVC Programming Model• MVC is one of three ASP.NET programming models.

• MVC is a framework for building web applications using a MVC (Model View

Controller) design:

1) The Model represents the application core (for instance a list of database records).

2) The View displays the data (the database records).

3) The Controller handles the input (to the database records).

Page 10: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Why MVC?  

• ASP.NET MVC helps to reduce the complexity of the web application by dividing an

application into three layers, Model, View and Controller.

• This separation (loose coupling) helps in some long term benefits like isolation of

components while development and also this separation provides better support for

test-driven development (TDD).

• ASP.NET MVC web site are good in performance and also easy to maintain. 

Page 11: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

How to Install MVC?

• Before going to install mvc first check what version of MVC already installed in Your

computer.

• To check what MVC version already installed in My Machine open control panel then

open add or remove programs dialogue box.

Page 12: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

How to Install MVC? (Continue…)

Page 13: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

MVC Release History   

Page 14: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

How to Download MVC 3 & MVC 4?

Page 15: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

EX

Page 16: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Introduction of ASP.NET MVC 4• ASP.NET MVC 4 is a framework for building scalable, standards-based web

applications using well-established design patterns and the power of ASP.NET and

the .NET Framework.

• Currently ASP.NET MVC 4 is supported in Visual Studio 2010 and Visual Studio 2012,

previous versions of Visual Studio does not support ASP.NET MVC 4 as of now.

• If you don’t have ASP.NET MVC 4 in your box then install MVC 4 for Visual Studio

2010 or else use Visual Studio 2012 to get started with this.

Page 17: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Creating First Asp.Net MVC Application

Page 18: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Step-1• If you choose .NET Framework 3.5 you are not able to see MVC 3 & 4 option in new

Project Box.

Page 19: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Step-2• If you choose .NET Framework 4.0 Then

Page 20: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Step-3• If you choose .NET Framework 4.0 Then

Page 21: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Step-4

Page 22: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Step-5

Page 23: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Step-6

Page 24: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Step-7

Page 25: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Step-8

Page 26: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Step-9

Page 27: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Advantage of MVC over Asp.Net WebForms in details ?

Page 28: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

MVC vs. WebForms

Page 29: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

MVC vs. WebForms• In WebForms whenever I want to execute any event say Button_Click() before that

page life cycle will execute first (you like or not doesn’t keep matter).

Page Life Cycle execute FirstThen event

Page 30: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

MVC vs. WebForms

Page 31: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

MVC vs. WebForms• In MVC direct hit come to action(method you want to be run)

Page 32: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Example

Page 33: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Continue…Namespace

Page 34: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Assembly & Controller used in mvc application

Page 35: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Running First MVC Application

Page 36: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

How to determine what version of mvc is being used by an existing mvc web application ?

Page 37: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

MVC Version info in existing Application

There are two ways :

1. At design time

2. At runtime

Asp.net mvc namespace:

Page 38: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Version Info:

Page 39: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

At runtime

Page 40: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Compare Asp.Net MVC & Web Application

1. Asp.Net MVC Application:

2. Web Application:

Page 41: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

MVC URL

http://localhost:1927/Home/Index

Server

Functions in Controller are generally called as Controller Action Methods.

In MVC’s URL are mapped to Controller Action Methods.

Page 42: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Web Form URL

http://localhost:1928/WebForm1.aspx

Server

In WebForm’s URL are mapped to physical Files.

Page 43: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

How to deploy application on IIS

1. Open IIS(start->run->type inetmgr)

Page 44: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

How to deploy application on IIS

2. Deploy application on IIS.

Page 45: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

How to deploy application on IIS2. Deploy application on IIS.

Page 46: Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models

Summary!!