Summer 2015 has come and gone (in the northern hemisphere at least!), and four releases of ASP.NET have hit the internet in that time. With the Visual Studio 2015 release in July the team released ASP.NET 4.6, a major update for our ASP.NET frameworks and tooling. Additionally, ASP.NET 5 beta 5 was released with Visual Studio 2015 so that developers could start to explore the new development framework. With several updates to ASP.NET 5 since that date, and the introduction of the new ASP.NET web hooks tools, there are many new features and capabilities to explore. In this post, we’ll focus on the newest features for web developers.
ASP.NET 4.6 – More of a good thing
With ASP.NET 4.6, developers working with Web Forms, MVC, WebAPI, Windows servers, and Internet Information Server have the latest C# tools and compilers for their favorite platform. In addition to providing support for C# 6 and VB 14, this release also brought support for HTTP2 on compatible servers.
Async Model Binding
Web Forms developers in ASP.NET 4.6 can now write model binding methods that run asynchronously and return Task objects on pages that are marked with an async=”true” page directive. No longer will the web server block threads while it is waiting for a database call when you have model-binding code like this:
publicasyncTask
GetTripFor([QueryString] string id)
{
var tripId = Guid.Parse(id);
returnawait dataContext.Trips.FirstOrDefaultAsync(t => t.Id == tripId);
}
Our id will be read from the querystring “id” parameter, parsed as a Guid and then passed to an Entity Framework query against the Trips collection in our dataContext. The best part is the use of the await keyword on the query will allow the operation in the database to run while the executing thread is returned to the ASP.NET threadpool.
.NET Compiler Platform
The new language features are available throughout ASP.NET, and are enabled by default when you create a new web application. If you want to add these features to a project that you are upgrading from an older version of ASP.NET, simply install the compiler platform NuGet package with the following command in the Visual Studio Package Manager Console:
Install-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
Tooling Improvements
We also brought support for new web development technologies and tools to Visual Studio. Starting with 2015, the JSON editor supports JSON Schema validation and provides IntelliSense based on known schemas.
The editor also supports SchemaStore.org– an open source collection of useful JSON schema files. Any JSON file that has a schema associated on schemastore.org will automatically get IntelliSense and validation support.
Support is now provided for bower and npm configuration files. This gives you the IntelliSense type-ahead that you would expect and gives you package information as you key in package names:
The HTML editor has been improved as well. The editor now has a better understanding of the common double-curly brace syntax {{…}}. This ensures that inner content is not treated as HTML and marked invalid by the editor. Developers using Angular, Mustache, Handlebars, and other double-curly brace templating languages benefit from this. The editor also now understands Angular directives and attributes. You’ll see icons and helpful hints when you start typing out that ng- attribute name:
The Bootstrap CSS framework receives similar treatment, with a special icon to indicate the various classes and capabilities of the Bootstrap framework, keeping them logically separated from any classes you have created:
The JavaScript editor has seen similar improvements, with support for AngularJS, ReactJS, and new JavaScript language features. Try out the new code navigation bar in the editor to assist in traversing large JavaScript files. If you are working with complex JavaScript scripts, you may want to decorate them with JSDoc comments to help document their features like you do with C# and VB code. The JavaScript editor now provides IntelliSense hints for writing your JSDoc markup and supports displaying this content as IntelliSense pop-ups in the editor.
More information about the tools and features of ASP.NET 4.6 can be found in our announcement blog post on the Web Development blog.
ASP.NET 5 betas
ASP.NET 5 is the name of the next generation web development platform that the team is working on. In addition to continuing to provide ASP.NET MVC and WebAPI development capabilities, this open-source platform promises to provide a cross-platform development and deployment experience. ASP.NET 5 projects can be developed, built, and deployed on Windows, Mac, or Linux operating systems.
The ASP.NET 5 team has released beta versions of the framework and tools every month, and has a published roadmap that they are tracking for a final release. With three beta releases over the summer, there have been a significant number of advancements in Web Development with ASP.NET.
ASP.NET 5 beta 5 shipped with Visual Studio 2015 and came with an initial set of capabilities to support development with a new version of ASP.NET MVC that was merged with ASP.NET Web API to become ASP.NET MVC 6. It supports developing web applications with Mac and Linux through the use of the open source Mono runtime. Other features include:
- C# 6 support in Razor markup
- A new JSON helper to assist in serializing JSON for views
- New tag helpers like ImageTagHelper and support for binding dictionary properties
ASP.NET 5 beta 6 shipped at the end of July and brought a bunch of non-breaking framework changes to improve developer’s interactions with ASP.NET. Additionally, the SQL Server distributed cache was introduced as well as strong name support for assemblies referenced by a web project. The MVC and WebAPI packages were refactored to allow them to stand on their own, enabling developers to grab just the parts of the framework they needed without inheriting the entire MVC framework.
ASP.NET 5 beta 7 was made available in early September as a pair of downloads from www.asp.net/vnext. These downloads update both the ASP.NET frameworks (dnvm, dnx) and the web development tools in Visual Studio 2015. This was a significant release for ASP.NET because it features the first public preview of the native .NET Core frameworks for Mac and Linux. No longer is the Mono framework required to run ASP.NET with these versions of .NET Core.
Some of the additional enhancements in ASP.NET 5 beta 7 include:
- dnx commands no longer require a directory to be specified at the command-line. You can simply execute dnx web to execute the web command in the current project folder.
- dnu restore output has been improved to report the nuget.config files and feeds used to retrieve packages.
- Incompatible package dependencies are reported better and appear cleaner in the Visual Studio 2015 error list.
- The dnx command-line supports a new –framework switch to specify which .NET Framework to use.
- When running with the full .NET Framework on Windows, the app.config file is supported.
- You can now specify the operating system for which a dnx should be installed when executing dnvm. This allows you to install a dnx for Linux on Windows and then public that app to Linux from Windows.
- Unit testing templates were made available through SideWaffle and the Yeoman ASP.NET Generators.
The Kestrel web server has been improving in leaps and bounds. In the beta 7 release we made a pair of performance improvements to allow chunked responses when no content length is specified and to allow write-behind buffering when writing responses to the network. We decided to make Kestrel our primary host that we will support, and discussed this in a recent ASP.NET Community Standup:
Tooling in ASP.NET 5 beta 7 has been improved to give a number of productivity improvements for web developers. We refactored the package search analyzer to now add only framework packages that you may be referencing when you execute a Ctrl+. hotkey.
Now when you start a project from Visual Studio, we enable the Debug Logger by default so that all Debug and higher severity messages are reported to the console. Finally, we added IntelliSense support to TagHelpers so that you can learn how to better use these extensions to the Razor markup.
A complete description of the important new features of the ASP.NET 5 beta 7 release are available on our announcement blog post.
ASP.NET Web Hooks
An exciting new extension to ASP.NET 4.6 was introduced in September called ASP.NET Web Hooks. With this new framework, you can integrate with internet services to send or receive webhooks. These webhooks are small messages that are sent between services when subscribed events are triggered on a service.
We have an extensive series of blog posts on how to configure receiving and sending webhook integration messages between web services. Check them out on the Web Development blog.
ASP.NET Community Standup
Each week the ASP.NET leadership team broadcasts a meeting where they discuss the latest features and changes to the web development framework. They take community contributions and questions, so this is your chance to have your voice heard by the team that is building the next generation of .NET web tools. Follow along with their broadcasts and review the already completed meetings at http://live.asp.net.
Summary
It’s an exciting time to be a web developer on the Microsoft application platform. With a new ASP.NET framework in open development, new compilers and features for the production-ready ASP.NET 4.6, and new innovative frameworks like WebHooks there is a lot to learn and start using. Visit www.asp.net and blogs.msdn.com/webdev to learn more about all of the latest web platform frameworks and tools.
Jeffrey T. Fritz (@csharpfritz) Jeff is a long time web developer who survived the dot-com era. He’s been writing web applications since the 1990s and currently is the program manager for the NuGet package manager. His two pre-teen daughters think he’s the coolest because he works at the same place as the Minecraft team. |