Archive

Posts Tagged ‘Mobile Website’

A Glance At ASP.NET MVC 4 Project Templates in Visual Studio 2012

17/08/2012 Leave a comment

Visual studio 2012 and .Net framework 4.5 was released yesterday so it’s a good time to take a look at new MVC framework (MVC 4) included in VS2012. If you are a interested in trying out, you will be able to download Express or  90 days trial version from here.

MVC 4 Projects
MVC 4 Application in Visual Studio 2012 exposes  6 different types of templates (projects) . Please let me to introduce you with them here.

MVC4 Project Types

MVC4 Project Types

Empty Application
Provides the minimum references and resources required to run an Asp.net MVC application.  As you can see  in below,  Models, Controllers, App_Data are completely empty folders.

MVC4 Empty Application Structure

MVC4 Empty Application Structure

App_Start folder which is new in MVC4 contains 3 configuration files. It is including  FilterConfig.cs, RouteConfige.cs and WebApiConfig.cs.  These classes are responsible for application configuration when your application is starting.  In fact, FilterConfig and RoutrConfig are not really new. RegisterGlobalFilters and RegisterRoutes methods have been extracted from MVCApplication class in Global.acax file and put in these separated files.

Refrences folder has been changed as well.  Entity Framework which was included in MVC3 has been vanished. Instead, Json.Net has been added. Also, Http programming has been empowered  by adding System.Net.Http class family. In Addition System.Web.WebPages family has been got richer by adding  System.Web.WebPages.Deployment and System.Web.WebPages.Rezore.

MVC3 Empty Application Structure

MVC3 Empty Application Structure

Views folder  just includes a Web.config file at the time being means _ViewStart.cshtml and Shared folder(including _Layout.cshtml & Error.cshtml) have been disappeared since  MVC3. Content and Scripts folders have been removed as well.

Basic Application
It’s a new project type in MVC 4 and it was not available in MVC3.  I personally think that Basic project is much much closer structurally to Empty project in MVC3. It includes Content and Scripts as well as few more references. Here is a short list of what’s included

Bundling and minimization facilities have been prepared in this template. BundleConfig.cs file has been added to App_Start folder. Additionally, what had been disappeared in Views folder came back to the board. _Layout.cshtml  includes the jQuery bundle as well as the default theme styling.

MVC4 Basic Application Structure

MVC4 Basic Application Structure

Internet Application
Adds tow controllers( Account controller and Home controller)  to the Basic template with implemented actions and views.  Membership management functionality which allows you register, login, change password and so on is implemented in Account controller and Home controller gives you Index, About and Contact actions working with their own related views. Its a template used usually to start a normal web project in action.

MVC4 Internet Application Structure

MVC4 Internet Application Structure

AuthConfig.cs in App_Start  helps you to allow your users log in using their accounts from other sites such as Microsoft, Facebook, and Twitter. Thanks to DotNetOpenAuth class family.  Account views have been empowered by adding few views and partial views to make it easy for you to have an external log in by other sites account in your websites.

Intranet Application
In fact, It’s  the Internet Application except for Membership management.  the Account controller and the web.config has been configured  to use Windows as it’s authentication method.

Mobile Application
Mobile website programming is one of  most important feature in MVC 4 so this template has everything that Internet Application template has, however it  is using  jQuery.mobile instead. In addition,  DotNetOpenAuth references for external log in functionality is removed.

MVC4 Mobile Application Structure

MVC4 Mobile Application Structure

Web API  Application
Its another new Template in VS2012 to make it easy to develop RESTful web services and applications to feed a vast variety rage of clients from desktop browsers to tablet applications. It allows you to expose your data and service to the web directly over  Http for more details visit here. This template includes everything from Basic Template expect Account controller and membership functionality and references However Value controller as a simple API example jumps in.

MVC4 Web API Application Structure

MVC4 Web API Application Structure

MVC 4 in Visual studio 2012 caters a wider range of  project templates which help developer to do their job easier and faster as well as following best practices and keeping development rules.

Thanks to VS2102 development team. Well done guys!