Announcing Availability of ASP.NET 5 beta 6
It feels like we just did this… we just announced an ASP.NET release, and here comes another one. The development team has been hard at work right through the release of Visual Studio 2015 to deliver an updated set of packages and tools for you to use with ASP.NET 5. This release, labeled ASP.NET 5 beta 6 contains a handful of new features in the framework and packages. Let’s take a look at how we can get started adding ASP.NET 5 Beta 6 to our Visual Studio 2015 install.
For the first time in the ASP.NET 5 beta cycle, we are publishing a new version of the Visual Studio web development tools with the updated framework. Previously, Visual Studio users would need to go through some significant changes in order to attempt to use the latest beta versions of ASP.NET 5 with their editors. Starting with this version, you can go to the download center and get directions on how to update Visual Studio and any other editor you may be using.
There are a number of changes and updates to how you can interact with the ASP.NET framework. None of these changes are breaking, and add significant functionality that you can use.
SQL Server Distributed Cache
The new Microsoft.Framework.Caching.SqlServer package will allow you to use SQL Server as your cache store in ASP.NET 5 applications. This enhancement allows you to cache your data when running ASP.NET in a web-farm scenario and the in-memory cache is no longer appropriate. You can configure your SQL Server Cache with the following steps in your project folder:
- Run dnu commands install Microsoft.Framework.Caching.SqlConfig to add a sqlservercache command to your workstation in the %userprofile%\.dnx\bin folder.
- Run sqlservercache create <connection to db> <schemaname> <tablename> to configure the cache on the database server
- Add a reference in your project to the Microsoft.Framework.Caching.SqlServer package
- Register the cache with the ASP.NET dependency injection in the ConfigureServices method:
- Add parameters to your objects where you would like an IDistributedCache injected.
You can read the official announcement about this library on the ASP.NET Announcement Repository.
Strong name support for assemblies
You can now mark assemblies in your build process for strong naming. The project.json file now has configuration options that can be set at various levels in the file for individual build configurations or framework version. You can choose to use Open Source Signing, delay signing, or create a full signature key file.
You can specify that your project should use Open Source Signing like this:
Alternatively, you can delay sign and specify your key file like this:
Place this section on the root of your project.json file to force all project configurations and frameworks to strong-name or you can place it inside an individual configuration element or framework element. For example, to force strong-naming for release configurations, I can have this configuration section in my project.json file:
Trailing Slash support
A feature from previous MVC framework versions that had not made it over the MVC 6 yet is the ability to configure routes to append a trailing slash. In MVC 6 this is a configuration option on the Microsoft.AspNet.Routing.RouteOptions class. To enable this feature, simply configure add the following RouteOptions configuration in the ConfigureServices method in the Startup class:
opts.AppendTrailingSlash = true;
Response Buffering and Caching now enabled for WebListener
With server applications it is important that we use all of the resources available to us in order to deliver great performance. When running ASP>NET 5 on Windows and IIS you get efficient response buffering and caching using the native response caching in HTTP.SYS. Starting with this beta you get the same support when running on WebListener. No configuration changes are needed to enable this performance boost. None. Nada. You get more performance for free whenever cache response headers are used, and that’s a good thing.
MVC and Web API Packages – Less is Better!
We know that a lot of ASP.NET developers are enjoying the MVC 6 implementation with Web API. It was a natural match that works really well together and has delivered some great experiences from the early feedback we are hearing. We have also heard from some developers who really like Web API and don’t want to have their application waste time loading other resources that Web API doesn’t use like Razor or TagHelpers.
Starting with beta 6, you can now consume a smaller subset of the MVC packages to allow you to work with Web API functionality and exclude other dependencies that you don’t need for your implementation. Typically when you work with MVC 6, you only need to include one package: Microsoft.AspNet.Mvc and you get all of the references you need through transient dependencies. You may also call this feature “indirect package references”, as this feature of the package manager allows all of the dependent packages that make up MVC and WebAPI to be included in your project with no extra code or configuration.
The update in this beta 6 version allows you to specify a subset of those indirect package references. In the scenario described above, where a Web API developer doesn’t want all of the Razor and TagHelper features, they can use a project.json configuration file with this subset of dependencies to deliver a Web API-only application:
This is an incremental release of the ASP.NET 5 frameworks and we hope that you download a copy of the ASP.NET 5 tools and framework and try it out. We have a long road still ahead of us, and we hope you follow our ASP.NET 5 roadmap and provide feedback on the features you like and don’t like. You can start by replying to this post and telling us what you think of these new features that were added. After that, stop by the next ASP.NET Community Standup on Tuesday and you can ask the ASP.NET 5 Program Managers any follow-up questions you may have.