"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Wednesday, November 28, 2012

Basics Of MVC 4 Day 1

Hi *.*,
Today i'm just giving an outline about MVC 4 and Creating a sample application too.
  
ASP.NET MVC is a framework for building web applications that applies the general Model
View Controller pattern to the ASP.NET framework. The MVC separates the user interface (UI) of an application into three main aspects:


  •  The Model: A set of classes that describes the data you’re working with as well as the business rules for how the data can be changed and manipulated
  •   The View: Defines how the application’s UI will be displayed
  •    The Controller: A set of classes that handles communication from the user, overall application flow, and application-specific logic
MVC 4

As we are directly going to 4th version of MVC, we had got lot of advantage
  •  Json support
  • JavaScript support 
  • Improved Visual Studio tooling,
  • Asynchronous controllers support,
  • The Razor view engine
  • Support for .NET 4 Data Annotations
  • Improved model validation
  • Greater control and flexibility with support for dependency resolution and global action filters
  • ASP.NET Web API
  • Enhancements to default project templates
  • Mobile project template using jQuery Mobile
  • Display Modes
  • Task support for Asynchronous Controllers
  • Bundling and minification
  • Service handling
And So On… 

Creating an ASP.NET MVC 4 Application
Here I’m using VS 2012 (my new favorite, it loves u back)I strongly recommend it. If u doesn’t have, try to get a trial or express version, it’s free from Microsoft official website.

Call vs 2012




File > Project> Select MVC 4 Web Application (Screenshot attached below checkout)

Here I’m planning to create a blog in MVC so I’m giving project name MvcBlogDemo.
Select a target path too (as per u want).






An intermediate dialog with some MVC-  specific options for how the project should be created .

 
Choose Templates


  •   The Internet Application template: it contain the basic of mvc application ,i.e. after creating it u can easily run and view some pages, more over basic account management functions is also integrated(ASP.NET Membership system).
  •   The Intranet Application template: Its similar to Internet Application Template here account management system run against windows account.
  • The Basic template: its intended to beginner plus level users, who want to setup thing as per their configuration. it’s just having MVC infrastructure in place only.
  • The Empty template: The Basic template used to be called the Empty template, but developers Complained that it wasn’t quite empty enough. With MVC 4, the previous Empty template was renamed Basic, and the new Empty template is about as empty as you can get.It has the assemblies and basic folder structure in place, but that’s about it.
  • The Mobile Application template: the Mobile Application template is preconfigured with  jQuery Mobile to jump-start creating a mobile only website. It includes mobile visual themes, a touch-optimized UI, and support for Ajax navigation.
  • Web API: ASP.NET Web API is a framework for creating HTTP services. The Web API template is similar to the Internet Application template but is created for Web API development. Instead of ASP.NET membership its working with standard MVC account management.

View Engines
 Next option to select view engine default it selected Razor (sexy beast).View
Engines offer different template languages used to generate the HTML markup in your MVC
Application

Testing
Another option is create unit testing with sample unit test. Leaving the Create a Unit Test Project checkbox unselected means that your project will be created without any unit tests, so there’s nothing else to do.
I recommend move with unit testing. On selecting that checkbox two textbox will appear. Test project name (go as u wish).Second select framework to be test.

Ok now let’s move back to project, select Internet application and Click Ok button.

MVC Structure
When you create a new ASP.NET MVC application with Visual Studio, it automatically adds several files and directories to the project,

Now Press F5


In my Next post,i will go going More details to MVC  :)



If u had any trouble just ask, Happy to help u :) 
Stay Tune... 
Have a nice day... 'N happy Coding :)

No comments: