Skip to main content Skip to footer

What to Expect in ASP.NET 5: Cross-Platform, Small Footprint, Single Web Stack and TagHelpers

ASP.NET 5 is ready for production! Microsoft has released RC1 with a go-live license. If you're planning to start a new project, ASP.NET 5 offers a cross-platform development experience that enables you to not only develop the application in a Windows\MAC\Linux environment, but also allows you to host the application on a Windows server or on Linux. In addition, ASP.NET 5 provides a host of new features that makes web development very easy.

ASP.NET 5 Tools and Runtime

The latest ASP.NET 5 tools and runtime can be downloaded from get.asp.net. You have options to choose the tools for Windows, MAC or Linux systems. Read more in the in-progress documentation.

ASP.NET 5 Salient Features

  • New lightweight and modular HTTP request pipeline
  • Ability to host on IIS or self-host in your own process
  • Built on .NET Core, which supports true side-by-side app versioning
  • Ships entirely as NuGet packages
  • Integrated support for creating and using NuGet packages
  • Single aligned web stack for Web UI and Web APIs
  • Cloud-ready environment-based configuration
  • Built-in support for dependency injection
  • New tooling that simplifies modern web development
  • Build and run cross-platform ASP.NET apps on Windows, Mac and Linux
  • Open source and community focused

ComponentOne ASP.NET MVC Edition Controls

C1Studio ASP.NET MVC Edition controls are fully compatible with MVC6. Moreover, these controls can be used with both full CLR and core CLR. The controls offer a unique option to use, HtmlHelpers, TagHelpers or both. We've released ASP.NET 5 RC-compatible builds through the GrapeCity Nuget, and you can get ASPNET MVC Edition by downloading C1Studio.

Understanding ASP.NET 5 Web Application Structure

ASP.NET 5's web application organization has changed drastically. Some highlights include:

Project Structure

  • The project file extension is renamed to .xproj
  • The entire solution is in a "src" folder
  • The build output gets saved in a artifacts folder

ProjectStructure

Project JSON

The Project.JSON file is used to define project server side dependencies and other settings.

ProjectJSON

wwwroot Folder

This folder is the root of the web application; it also stores all static files. The wwwroot folder is the default web root folder, and the specific web root folder can be configured in project.json.

wwwroot

Dependency Management

The server side dependency is handled by references in the Solution Explorer. It contains dependency for each CLR runtime, i.e, full and core CLR. It has two types of dependencies: assemblies and Nuget packages.

Server Side Dependency Management Server Side Dependency Management

Application Startup

ASP.NET 5 has a modular architecture wherein we can opt in the services required in the project. This makes a lean architecture with small footprint. The Startup.cs files has two methods:

  • ConfigureServices include those services that will be available in the project. Any service that is not added in this method cannot be called or used.
  • Configure method is used to tell the Request pipeline which services to use, and is called after ConfigureServices.

Startup.cs Startup.cs

Framework

The project can target different frameworks and their versions. For example, you could target the project to use full CLR or core CLR.

Target multiple frameworks Target multiple frameworks

Razor code and TagHelpers

TagHelpers are new to MVC, and we've been supporting it since Beta4. TagHelpers allow you to declare MVC controls in a style closely related to markup. Visual Studio provides IntelliSense and color formatting that makes writing Razor code easy. You no longer need to use escape sequences like "@" to write some html or CSS class in the razor code, but you still get the advantage of jumping to C# inside quotes.

Here's a small example of how a label is declared using HtmlHelper and TagHelper. Notice how clean the TagHelper code looks—it's as if you're writing mark-up.

HtmlHelper

@Html.Label("FirstName", "First Name:", new {@class="caption"})  

TagHelper



TagHelper Form Example

















































This example demonstrates a Form with various input elements. Notice that form has a asp-for attribute; this sets the controller action to the form. You'll also notice that each control has a "for" attribute, which sets the model property to which the control is bound. We can set variables from the ViewBag inside the quotes, as well. For example, refer the item-source of C1AutoComplete control. It sets the source-collection attribute to "countries" variable, which itself is a List of countries.

Let's see some advance control examples:

FlexGrid

              allow-sorting="@Convert.ToBoolean(optionsModel.Options["Allow Sorting"].CurrentValue)"   
              selection-mode="@((SelectionMode)Enum.Parse(typeof(SelectionMode), optionsModel.Options["Selection"].CurrentValue))">   
                             is-visible="@(string.Compare(optionsModel.Options["Column Visibility"].CurrentValue, "show", true) == 0)">   
                             format="@(optionsModel.Options["Formatting"].CurrentValue == "On" ? "MMM d yy" : "")">   
                             format="@(optionsModel.Options["Formatting"].CurrentValue == "On" ? "HH:mm" : "")">   
                             width="@optionsModel.Options["Column Resize"].CurrentValue">   








FlexChart








MESCIUS inc.

comments powered by Disqus