ASP.NET 5 Beta7 is the brand new version of the popular developer framework. It is now available on NuGet, and also in Visual Studio 2015, as a tooling update. Here is a preview of what is in store in the new version, and how the changes on offer would impact developers.
Cross Platform Support for DNX
The .NET Execution Environment (DNX), which offers a reliable way to build and run cross-platform .NET projects acts as the basis of ASP.NET 5. DNX is still work in progress. During the previous releases, while framing DNXs for the full .NET Framework, Mono, and .NET Core, the DNX for .NET Core was limited to Windows only. ASP.NET 5 Beta7 extends DNX for .NET Core to both Mac and Linux, with limitations. With the limitations imminent to go away in future releases, the “Mono” is all set to become redundant.
ASP.NET 5 Beta7 improves DNX in other ways as well. There is now improved visibility into the package sources used after doing a `dnu restore.’ The error messages that are generated on having incompatible package dependencies have improved as well, to offer meaningful insights. A new framework switch makes it possible to specify which .NET Framework version has to run.
In addition to this, the OS flag may now be used to specifically mention the OS, while installing DNX using DNVM (.NET Version Manager). This makes it possible, to say, install a DNX for Linux on Windows and then publish an app with a Linux runtime from a Windows machine.
Tweetable quote: “Does ASP.NET 5 Beta7 cross platform support the beginning of the end of Mono?”
Other Improvements in DNX
ASP.NET 5 Beta 7 offers better representation for DNX. DNX now looks in the current folder, by default, to execute a project. Specifying the path for the DNX project to run has become much easier. There is no longer a need for typing “.” Users may now simply enter “dnx web” instead of “dnx.web.”
DNX based projects now have the option to refactor the class name when the file name for the class is changed. It is now possible to use System.Configuration to access configuration data in app.config from a DNX based console application, when running the full .NET framework.
Improvements in Testing
Another major area of improvement that ASP.NET 5 Beta7 brings about is in the testing sphere.
New unit testing templates are now available. The latest release packs in a new xUnit.net Test Project from SideWaffle, allows the developers to start with unit testing for DNX based projects in short span of time. Also, it now becomes possible to use Yeoman ASP.NET generators to generate a unit testing project from the command-line easily.
Hitherto, it was possible to only write and discover synchronous unit tests for DNX projects. The new release makes it possible to write and discover asynchronous tests as well.
Improvements in Kestrel
Kestrel, the libuv based web server for ASP.NET vNext has undergone several improvements in ASP.NET 5 Beta7. It now supports writing chunk of responses automatically, when there is no content length specified for the response. It also starts to use write-behind buffering, to ensure that written responses are more efficiently captured in the network. These improvements add to the strength and resilience of the code.
Improvements in MVC/Razor
MVC/Razor is another area that has undergone noticeable improvements in ASP.NET 5 Beta7.
Hitherto, the comment blocks on the razor view engine led to the introduction of unnecessary white space in the rendered view. Razor now removes this whitespace by itself, when the entire line consists of a Razor block.
Rendered views now spot a cleaner look and consume less bandwidth.
Hitherto, it was difficult to expose the logic of a ViewComponent as a standalone endpoint. A new ViewComponent Result in MVC returns the result of a ViewComponent from an action, facilitating this action very easily.
The improved MVC handles URLs containing a ~ in a better way. Razor refers to the root of the application with ~, and this created problems when there were other occurrences of ~ in the views, for Razor would assume the same as application web root. Support for ~ is now moved out of Razor, into a new UrlResolutionTagHelper, thereby restricting the handling of ~ to only “src and href” attributes of well-known HTML elements. This does away with the problem.
Improved Tag Helpers
At times, multiple Tag Helpers work in conjunction with each other, and one Tag Helper is the parent of another. A classic example is the rows and columns in a grid. The new Beta7 improves Tag Helpers, making it possible to attribute whether an element is “parent,” or “child.” Using RestrictChildrenAttribute makes it easier to specify how these elements should work together. The parser throws an error on detecting other elements, thereby facilitating a better editing experience.
The new feature also adds support for elements without end tags, so that Tag Helpers apply to an element even when it has no end tag. Tag helpers also get support for conditional attributes.
Improvements in Tooling
Tooling is another area that has undergone improvements in ASP.NET 5 Beta7. Users now have the option of refactoring class names when file name of class is changed, in DNX projects. ASP.NET 5 project templates now include debug logger, and the HTML editors offer tool tips for Tag Helpers.
Revamped Project templates
ASP.NET 5 Beta7 has revamped current project templates.
The new project templates in Visual Studio include the debug logger by default, making the logged messages visible in the Output window. This is a convenient feature for developers and would speed up development work.
The folder structure of the ASP.NET 5 project templates goes updated, and now offers clean separation between data models and view models.
The new ASP.NET 5 Beta7 with its path-breaking introduction of new features, brings in several tweaks that make the life of the developers much easier, and also brings in much needed efficiency to the code.
Have you tried out the new features in ASP.NET 5 Beta7? Share your experiences with us in the comments box below.