Top 5 Changes in Asp.Net 5 and MVC 6

large variety of changes have been incorporated in Asp.Net 5 and MVC 6. Asp.Net 5 is rebuilt from scratch for the support of modern services and Web applications.

It is cross-platform; open-source and works both on the cloud as well as on-premises. Asp.net 5 is considered as the most significant release of Asp.Net over the history of .Net framework.

Following are the top 5 most changes made in Asp.net 5 and MVC 6.

1. Asp.Net on Linux and OSX:

The applications of Asp.Net 5 can be executed on Linux as well as OSX along with Windows. It opens Asp.net to an entirely new audience of designers and developers.

Traditional Asp.net had professional developers and designers working in a cooperative manner in the Windows machines. However, startups make use of Linux/OSX.

Enabling application development on Linux/OSX will change everything. Designers and developers can build their apps with Asp.net 5 in their favourite environments like WebStorm and Sublime Text without any difficulty.

2. No Web Forms and Visual Basic:

The Asp.Net WebForms are no longer the part of Asp.net 5.  However, it is possible to create apps of Web Forms in Visual Studio by targeting .Net framework 4.6. But these apps cannot take any benefit of the new features in Asp.net 5.

Asp.Net 5 supports only C#. There is no support for Visual Basic.

3. Support for Client-Side development-AngularJS, Grunt, Bower, Tag helpers:

AngularJS is considered as the most significant client-side framework for creating Single Page Applications (SPAs). The templates of Visual Studio version 2015 contain the controllers, directives, modules and factories of AngularJS.

Another important feature in Asp.Net 5 is the tag helpers. These have greatest impact on creating views in Asp.Net MVC application. Tag helpers can be used in much better way as compared to the MVC helpers used traditionally.

The new form element in Asp.net MVC 6 has only the HTML elements. As an example, instead of the Html.TextBoxFor () tag helper, it uses the INPUT element. A new attribute asp-for has been added in Asp.Net MVC 6. The main use of these elements is to extend elements with the server side functionality of Asp.Net MVC.

Moreover, Asp.net 5 gets lots of love from front-end developers because it supports Grunt (Gulp). GruntJS is a kind of task runner that allows developers to create resources such as CSS and JavaScript files.

As an example, GruntJS can be used for concatenation and minification of JavaScript files while performing a build.

Many GruntJS plugins are available for performing different tasks.

Two package managers beyond Nuget need to be supported for supporting GruntJS. Since the plugins of GruntJS are distributed in the form of NPM packages, Microsoft has added support for the same.

Also, Microsoft has added support for the Bower multiple client-side resources are distributed via Bower.

4. Unified Web API and MVC Controllers And View Components:

The Web API controllers were different than the MVC controllers in other versions of MVC. The MVC controller makes use of the System.Web.MVC.Controller class while the controller of Web API uses the System.Web.Http.ApiController class.

In case of MVC 6, only a single controller class is used for both the Web API and the MVC controllers. The only class available in MVC6 is Microsoft.Asp.Net.MVC.Controller.

An IActionResult is returned by controllers of MVC6. It may be used as a view when an MVC controller is used. IActionResult may be used as data in case a controller of Web API is used. Moreover, both the Web API and the MVC controllers use same routes in MVC6. Developers can make use of both attribute routes and the routes based and convention and can apply them all controllers of the project.

MVC 6 no longer contains the subcontrollers. Instead, view components have been added in MVC6.  Previous releases of Asp.Net MVC make use Html.Action () method for invoking a subcontroller. However, the Html. Action helper method is not contained in MVC6 version.

Rather, an alternative technology termed as View Components is used for the same. View Components are similar to the subcontrollers which have always been odd. They presented as they were actions of controllers but actually they were not. View components seem to be more natural.

5. Asp.Net Dependency injection and xUnit.net:

Asp.net 5 has support for the pattern of Service Locator as well as the dependency injection. That is, now there is no need to depend on third party frameworks of dependency injection such as AutoFac and Ninject.

With the help of dependency injection, the developers just need to declare the required dependency in constructor and it will be passed in with the help of Asp.Net 5 framework.

However, before it is implemented, one extra step needs to be performed. It is needed to register dependencies in the startup object to inform Asp.net about the same. As soon as a FooService, BazService and BarService is registered, the framework will realize the need to create a BazService and BarService for constructing FooService before it is passed to the controller.

Moreover, the Visual studio testing framework no longer exists in Asp.Net 5. Rather, it contains the xUnit.net framework for testing purpose.  Two attributes known as [TestMethod] and [TestClass] were used for describing a unit test in unit testing framework.
However, the xUnit.net framework in Asp.Net 5 makes use of the [Fact] attribute rather than [TestMethod] attribute. No [TestClass] attribute exists in this framework.

An example of code snippet using xUnit.net framework is shown below.

public class Tests
{
[Fact] public void SumofNumbers ()
{
// Arrange
var testcalculator = new Calculator ();
// Act
var result = testcalculator. SumofNumbers (1, 1);
// Assert
Assert. Equal (result, 13);
}

Alex Street

Alex likes to write about anything related to technology, marketing and gadgets. He sometimes reviews the latest tech and also writes on other blogs.

Add comment