Tuesday, February 28, 2012

ASP.NET MVC 4 Beta : Internet Application Preview

ASP.NET MVC 4 Beta is out! I installed it on my machine this morning. Here's a preview
  • One can install ASP.NET MVC 4 Beta from the MVC4 page. http://www.asp.net/mvc/mvc4
  • Top Features include Web API,  Mobile Project template, Mobile Apps features, Recipe based Code Generation. Full feature list can be found in the release notes.
  • Software requirements: Visual Studio 2010 with SP1, Visual Web Developer Express with SP1

Ok! After installing ASP.NET MVC 4 Beta. we can observe that there's a new project template added to the list. Notice that ASP.NET MVC 4 exist in parallel to the ASP.NET MVC 3 and MVC 2.


If we go ahead and create a new project name and say OK, we notice that there are a couple of additional project templates, than what we find in an MVC 3 project template list.

These are
  • Mobile Application
  • Web API
  • Single Page Application
In an MVC3 Project template, we have these types:



Awesome! We are just going to go with the Internet Application for now. Lets see how it is different from MVC 3 starter app. We can take a look at the other apps in later posts.

Notice that the "Use HTML5sematic markup" is no longer present. in ASP.NET MVC  4 Project Template group. Now let's take a look at the project structure. There are a couple of file of interest.
  • favico.ico.  You can read my post about Favorite Icons here.
  • packages.config.The packages.config file configures NuGet packages.




 Next, if we run this project without touching anything, we can see that the pages have been beautified and are in HTML5. There are links to facebook and twitter at the bottom.





Looks cool. Viewing the source in the browser will tell us that the site is HTML 5 based, with the usage of header, footer, section tags.

If we take a look at the components downloaded as a part of the request to the page in Firebug,
we can notice a couple of  interesting things.


At the end of the css and js file requests, there is some random text following a ? such as
http://localhost:58625/Content/css?v=oI5uNwN5NWmYrn8EXEybCIbINNBbTM_DnIdXDUL5RwE1

Similarly, on the js file request. If we take a look at the _Layout.cshtml file in the shared folder, we can see that we are using a different way of embedding css and js. We are passing the folder paths to a .NET Type.


This is basically a package that is included in the packages.config file, used to bundle and minify css and js files. These are website optimization techniques to make websites faster. Sweet.

Now, the last thing we shall look is at the global.asax file. There is an interesting thing going on here.
A new route is being registered here. This is named "DefaultApi" and the method routes.MapHttpRoute() is being used to a register a new type of route.



Basically this is for the Web API stuff. But it's in here in this project template too.

That finishes a quick tour of the new ASP.NET MVC 4 Beta Internet application. A couple of new things but other project types such as the Web API will be more interesting and will cause a lot of
uproar in the development community!


No comments:

Post a Comment