About MVC4

Hello Everyone,

I want to share some ideas about MVC4. This is useful for all kind of beginners who wanted to get started with MVC4. I learned all these things & really it’s a nice experienced for me. It is useful in future also. I just explain you following things about MVC4 in short.

  • Introduction
  • Basic Concepts
  • How MVC works?
  • Advantages
  • Features & so on…….

Introduction:

ASP.NET MVC 4 (Model View Controller) is open source. It helps to reduce the complexity of the web application by dividing an application into three layers, Model, View and Controller.

Steps for creating MVC4 application in visual studio 2010/1012:

  • First Select New Project from the Start page or you can use the menu and select File -> New Project.

MVC

  • You can create applications using C# or VB as the programming language. Select C# and then select ASP.NET MVC 4 Web Application.

MVC1

  • Give a name to your project and then click OK.
  • Select Internet Application & Leave Razor as the default view engine & click OK.

MVC2

Basic Concepts:

  • View Engines are used for designing. It is responsible for rendering the HTML from your views to the browser. The types of four view engines are as fallows:
  1. ASPX (C#)
  2. Razor (CSHTML)
  3. NHaml
  4. Spark
  • Name of different return types of controller action method are:
  1. View Result
  2. JavaScriptResult
  3. RedirectResult
  4. ContentResult
  5. JsonResult
  6. EmptyResult
  • The three segments of default route, that is present in ASP.NET MVC application are:
  1. Controller Name
  2. Action Method Name
  3. Parameter that is passed through action method
  • MVC File Structure & File Naming Standards:

It uses a standard directory structure and file naming standards. There must be 3 directories each for model, view and Controller. Expect from these 3 directories, there must have a Global.asax file in root folder, and a web.config.

  • Root
  • Controller
  • Controller CS files
  • Models
  • Model CS files
  • Views
  • View aspx/ascx files
  • Global.asax
  • Web.config

Framework:

The pictorial representation of MVC framework is as follows:

MVC3

An MVC application consists of Model, View and Controller.

  1. Model: It consists of the method definations, data access logic and Business Objects.
  2. View: A view is used for user interface.
  3. Controller: It call views. It consists of the main application flow logic.

Advantages:

The main advantages of ASP.net MVC are:

  1. Enables the full control over the rendered HTML.
  2. Provides clean separation of concerns.
  3. Enables Test Driven Development.
  4. Easy integration with JavaScript frameworks.
  5. No ViewState and PostBack events

New Features in MVC4:

  • ASP.NET Web API

-It consists following features:

  • Modern HTTP programming model
  • Full support for routes
  • Model binding and validation
  • Improved testability
  • Code-based configuration
  • Create custom help and test pages
  • Link generation
  • Refreshed and modernized default project templates
  • New mobile project template
  • Many new features to support mobile apps
  • Enhanced support for asynchronous methods

If you know more about this then please share.

Thank you…..

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s