Introduction to ASP. NET 5 & MVC6 series (1): Introduction to ASP. NET 5 and introduction to ASP. NET

Source: Internet
Author: User

Introduction to ASP. NET 5 & MVC6 series (1): Introduction to ASP. NET 5 and introduction to ASP. NET

Introduction to ASP. NET 5

ASP. NET 5 is a cross-era rewrite. All functions and modules are independently split and completely decoupled. For these changes, Microsoft also made a fight. Almost all. NET Framwrok was rewritten to form a. NET Core. In. NET Core, everything is configurable, including Session, MVC, and other functions. All configurable functions can be downloaded on Nuget.

Currently, ASP. NET 5 is still compatible with the old. NET Framwrok. However, to deploy it across platforms, you can only use the new. NET Core CLR.

Currently, ASP. NET 5 includes six sub-projects: DependencyInjection, EntityFramework, Identity, KRuntime, MVC, and SignalR Server. Each project is described as follows:

DependencyInjection-Basic dependency injection management and default implementation
EntityFramework-Data Access ORM framework
Identity-User Authentication System
KRuntime-core runtime, project system, loader
The MVC-MVC framework integrates the MVC, Web API, and Web Pages functions.
SignalR-Server-real-time interactive service

The open source code of all ASP. NET 5 subitems can be found at https://github.com/aspnet.

ASP. NET version

5

The new version of ASP. NET, known as ASP. NET 5, is a framework for developing web applications using the MVC Architecture. It also provides the function of developing RESTful services. In addition, in the next version, the framework can also use SignalR to build real-time applications. Note that ASP. NET 5 no longer contains the Web Form development framework.

5 is also the version of the new version of. NET framework, called Core50, also known as. NET Core .. NET Core is a restructured version of. NET. It only retains the minimal feature set in the original framework. For other features and features, you can download and run it as a plug-in through nuget. This means that we can use it for independent deployment in various cloud environments. In addition, Microsoft also provides a cross-platform. NET Core that allows ASP. NET programs to be deployed on Mac and Unix/Liunx servers. In addition, the. NET Core framework can be packaged and deployed together with programs, so that different versions of. NET Core can be used on the same server.

In addition, it should be noted that. NET Core does not include Web Form, Windows Form, WPF, WCF, Silverlight, System. Drawing, Datatable, and other functions. That is to say, if your program needs to use System. Drawing for thumbnail creation, it will be useless. Similar tool sets can only be downloaded through the Nuget package. You can use a tool to find the compatibility tool set of the current program and. NET Core.

4.5.2

4.5.2 is the version number of the current. NET framework full-featured version. You can use this version of. NET to run ASP. NET 5 or even version 4.5.1. With this version, you can use all the functions of the entire. NET system, but it cannot be cross-platform.

4.6

4.6 is the next version of the. NET framework full-featured edition. It is also the next version of. NET Core. You can run ASP. NET 5 applications on. NET 4.6, but ASP. NET programs running on. NET 4.6 may be incompatible with. NET Core. The next version of ASP. NET Web Forms is also 4.6, which will include some enhancements, such as asynchronous model binding, HTTP2, and start using the Roselyn compiler. Existing ASP. NET programs (Web Forms, MVC5, previous versions, and Web Pages) can run on. NET 4.6 without any modifications.

6

The MVC, Web API, and Web Pages frameworks in ASP. NET 5 are merged into one framework, collectively known as MVC6. This merge operation will delete repeated functions in the three frameworks. For example, only one type of Controller is retained in MVC and Web API. However, traditional MVC functions are retained, such as model binding. However, it is said that Web Pages will not be released during RTM, but will be released in the first update after RTM.

MVC6 will introduce some new features, the most striking features are Tag Helpers and View Components. Tag Helpers is a replacement of Html Helpers, while View Components introduces the concept similar to WebControl in Web Forms.

For example, the original view model is defined as follows:

@using (Html.BeginForm("Register", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" })){  @Html.AntiForgeryToken()  

In the new version of MVC6, we can use Tag Helper for definition:

<form asp-controller="Account" asp-action="Register" method="post" class="form-horizontal" role="form">  

In this way, it greatly facilitates front-end developers, because they can see the normal HTML structure.

View Components solves the Child Action problem. For example, in many cases, we use Html. Action to Implement the menu and tag functions. The following is an example of View Component:

  public class GreetingViewComponent : ViewComponent  {    public IViewComponentResult Invoke()    {      var greeting = "Good Morning!";      if (DateTime.Now.Hour > 12)      {        greeting = "Good Afternoon!";      }      if (DateTime.Now.Hour > 17)      {        greeting = "Good Evening!";      }      return View("Index", greeting);    }  }

The view component (view component) also needs to respond to the view File, for example:

@model string

To call the code, you need to use the permission Component. Invoke method, for example:

<div>  @Component.Invoke("Greeting")</div>

There is also a Component. InvokeAsync method that can be used for asynchronous calls. For detailed usage of view components, see view components.

7

7 is the next version of Entity Framework. Although it is not part of ASP. NET 5, it has a lot to do with it. EF7 and ASP. the RTM version of NET 5 is released together. Although it may be postponed, at least one of the following versions can be released at that time. the basic ORM package running on. NET Core does not include delayed loading, inheritance ing, and is only applicable to SQL Server. If you are not running the MVC6 program across platforms, you can continue to use EF6 in. NET 4.5.2 or 4.6,
10 major changes in ASP. NET5 and MVC6

In the new ASP. NET5 and MVC6 have many changes, some of which are thorough changes. For example, the dependency injection technology is supported at the bottom layer. To facilitate understanding, we listed the 10 most important changes here, for learning, the details are as follows:

ASP. NET 5 is now cross-platform and can be run on Mac and Linux.
There is no longer a Web Forms framework.
Only C # is supported, and VB. NET is not supported. (It seems that the final version of VB. NET will be supported again recently)
New Tag syntax, @ Html. labelFor or Html. replace TextBoxFor with the new syntax <label asp-for = "Name"> or <input asp-for = "Name"/> for model binding.
View Component is added to define partial content as a separate Component for calling, which is very similar to WebControl in Web Forms.
The front-end technology is embraced, with built-in Nodejs, NPM, Grunt, and Bower technologies.
Model Integration integrates MVC and WebAPI into a framework.
Supports AngularJS and provides built-in modules, controllers, direve ve, and factory templates for AngularJS.
Supports dependency injection technology, a native DI framework, and third-party containers.
Supports xUnit.net and discards the Visual Studio Unit Testing framework.

IDE

VS2015: not to mention VS2015. It is still very tall. Currently, it not only supports Nodejs and Python development, but also Android and iOS development.
Visual Studio Code: in order to be able to write C # programs on Mac or Linux operating systems, Microsoft released a lightweight Visual Studio Code editor that can use the above operating system, new Features and features instantly spike Sublime Text and Brackets, visit: https://code.visualstudio.com/for details /.

Reference: http://stephenwalther.com/archive/2015/02/24/top-10-changes-in-asp-net-5-and-mvc-6

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.