📜 ⬆️ ⬇️

Introduction to ASP.NET 5


The first preliminary release of ASP.NET 1.0 was released almost 15 years ago and since then millions of developers have used it to create and run various applications. And over the years we have added a huge amount of code and features.

Today I am very excited about the news about the new release of ASP.NET, which our team is working on, which is called ASP.NET 5. This release is one of the most significant architecture updates we have ever done. As part of this release, we have made ASP.NET more compact, modular and cross-platform, as well as oriented to cloud hosting. ASP.NET 5 Preview is available for download in the latest Visual Studio 2015 CTP, which has become available quite recently.

ASP.NET 5 is an open source web framework designed to create modern web applications and work on Windows, Linux and Mac. It includes the MVC 6 framework and the Web API. ASP.NET 5 will also become the base for SignalR 3. Initially, ASP.NET 5 is designed to work on .NET CoreCLR, but can also be run on the full .NET Framework.
')
With ASP.NET 5, we made a number of architectural changes that made the web framework's kernel much more compact (it no longer needs System.Web.dll) and modular (now most of the functions are done in the form of NuGet packages, allowing you to have only that you need). With ASP.NET 5 you get the following changes:

And as an end result - ASP.NET, with which you are well acquainted, but which has become much more well-tuned for the modern realities of web development.

Flexible, cross-platform runtime


ASP.NET 5 runs on two runtimes to give you a choice: where to host your application. Runtime selections are as follows:

.NET Core is a completely new, cross-platform runtime that weighs almost nothing. When you choose .NET Core, you can take advantage of completely new benefits:
1) You have the right to deliver .NET Core runtime directly with your application, and this means that your application will work on it, and not on the version that is installed in the system. Your version of rutime will work side by side with other versions that pull other applications. You can upgrade your runtime version to a newer one without the fear that it will affect the work of other applications. This makes the deployment of new versions of applications and framework much easier and makes it possible to update while other applications are running.
2) Your application depends only on the features it really needs. Thus, you will never be asked to update those services that are not relevant to your application. This makes application deployment much faster and easier without affecting the operation of other applications.
3) Your application can now be cross-platform. We will provide you with a cross-platform version of .NET Core for Windows, Linux and Mac OS X. Regardless of which operating system you choose to develop and which operating system you choose to deploy, you can use .NET everywhere. Cross-platform version of runtime has not yet been published, but we are actively working on it and promise to roll out the official Preview very soon.

.NET Framework - The .NET Core API is currently much more limited when compared to the full version of the .NET Framework, so you will probably have to make a number of changes to make your application run on .NET Core. If you do not want to update your application, you can run it on ASP.NET 5 on the full .NET Framework (version 4.5.2 or higher). By doing this, you get the full set of .NET Framework APIs, and your applications will work without any changes.

MVC 6 is a unified programming model.


MVC, Web API and Web Pages provide additional functionality and are often used together in solution development (SLN). However, in the early releases of ASP.NET, these frameworks were developed separately, and therefore contained a huge amount of duplication and inconsistency. With MVC 6, we combined all these models into a single programming model. Now you have the opportunity to create web applications that contain both Web UI and services without the need to “reconcile” the differences between these frameworks. You can also completely smoothly translate your simple Web pages application into a modern and reliable MVC.
Now you can return Razor views data from the same controller and using the same MVC filter pipeline.
In addition to the unification of existing frameworks, we add new features that make server development easier. For example, Tag helpers. They allow you to use HTML helpers in your views simply by expanding the semantics of tags in the markup:
Those. instead of writing like this:
@Html.ValidationSummary(true, "", new { @class = "text-danger" }) <div class="form-group"> @Html.LabelFor(m => m.UserName, new { @class = "col-md-2 control-label"}) <div class="col-md-10"> @Html.TextBoxFor(m => m.UserName, new { @class = "form-control" }) @Html.ValidationMessageFor(m => m.UserName, "", new { @class ="text-danger" }) </div> </div> 

You will write like this:
 <div asp-validation-summary="ModelOnly" class="text-danger"></div> <div class="form-group"> <label asp-for="UserName" class="col-md-2 control-label"></label> <div class="col-md-10"> <input asp-for="UserName" class="form-control" /> <span asp-validation-for="UserName" class="text-danger"></span> </div> </div> 


Tag helpers make your presentations more “natural” and readable. They also make it easier to customize the output of HTML helpers.

For other examples of MVC6 applications, please follow this link: tutorials

Modern Web Development


This week we have released the ASP.NET 5 preview, which among other things includes some features that will allow you to make applications a little better:

Dynamic Development
In Visual Studio 2015, we will use dynamic compilation. You no longer have to recompile the applications each time to see the changes. Instead, just (1) change the code, (2) save the changes, (3) refresh the browser and (4) - you will see how your changes automatically update the application.


You will gain new development experience, which is now more like working with interpreted languages ​​than working with compiled languages.

You can also use other code editors (for example, Sublime Text 3 with the add-in for working with C # projects) to work with ASP.NET 5 projects. Any Visual Studio feature can be found in command-line tools, which meanwhile are cross-platform (this means that edit-in-place is also available on Mac OS X and Linux).

Integration with popular web development tools
Another feature of the future MS Visual Studio 2015 is the built-in support for Bower, Grunt and Gulp - popular open source projects, which, in our opinion, should be indispensable tools for each developer.


Bower: To add a JavaScript library to your ASP.NET project, add it directly in the bower.json configuration file:



Don't forget that Visual Studio provides you with IntelliSense with a list of available packages. The next time you open the solution, Visual Studio will automatically repair all the missing packages, so there’s no need for you to put them all into the version control system.

For server side packages, of course, you should use NuGet.

Grunt: in modern Web development, you can notice that you are doing a lot of different and different tasks from the development just to build your application: you collect LESS, TypeScript, CoffeeScript files, minify JavaScript, run JS unit tests, and so on, and so on ... In addition, each team has its own set of requirements, which are based on the toolkit used in the project. Task managers make it easier to coordinate and manage these tasks. Visual Studio supports two of the most popular runners: Grunt and Gulp.

Here is an example: for example, you need Grunt to collect LESS files. Then you should open the package.json and add the grunt-contrib-less package, which is a third-party plugin to Grunt.



Use the Task Manager Runner Explorer in Visual Studo 2015 to assign a task to a specific build step (pre-build, post-build, clean, or when the SLN file is open).



This makes automation of common tasks a truly time-consuming operation.

Simplified dependency management
In ASP.NET 5, you manage dependencies by adding / removing and updating NuGet packages. You can use the NuGet package manager, or simply edit the JSON file (project.json), which contains the list of NuGet packages and the list of versions that are used in your project. The project.json file is easy to work with, and you can of course edit it in any file editor, which allows you to update dependencies when your application is running in the cloud.
Project.json looks like this:



In Visual Studio 2015, IntelliSense helps you find available NuGet packages that you can add as dependencies:



IntelliSence will also help you with a list of available versions:


Open source


We are developing ASP.NET 5 in an open GitHub repository. You can see the code and see all the changes that have been made by us or the community. You can download this code, make changes to it and make a Pull Request. We believe that by opening the source code, we give you the opportunity to understand what is happening inside the product or, after sorting out everything, to start making changes to ASP.NET on our own.


Want to know more about .NET internals?



Then come to us at the light! In a short time in Moscow (April 03–04), Yekaterinburg (May 17) and St. Petersburg (May 29–30) a series of CLRium # 2 seminars will be held (live streaming is on). We will discuss the future of .NET: let's talk about the anatomy of the new CoreCLR, ASP.NET 5, features of RyuJIT, hardcore examples of working with Roslyn and CoreFx giblets! An endless stream of interesting and useful knowledge will help you not only understand better how your own C # programs work, but also prepare you for a brighter .NET future in which you can use the power of the platform to the fullest!

clrium

Source: https://habr.com/ru/post/253349/


All Articles