Introduction to ASP. 5

Source: Internet
Author: User
Tags sublime text

Introduction to ASP. NET 5 5 & MVC6 Series (1): Introduction to ASP. 2015-05-13 09:14 by Uncle Tom, 3379 read, 39 reviews, Favorites, compilation Introduction to ASP. 5

The ASP. NET 5 is a cross-age rewrite, with all the functions and modules being split independently and completely decoupled. For these rewriting, Microsoft is also very hard, almost the. NET Framwrok all rewritten, forming a. NET core thing. Everything in. NET core is configurable, including sessions, MVC, and all configurable features that can be downloaded on nuget.

Currently, the ASP. NET 5 is still compatible with the old, Framwrok, but you can only use the newly revised. NET Core CLR for cross-platform deployment.

The current ASP. NET 5 includes 6 sub-projects Dependencyinjection, EntityFramework, Identity, Kruntime, MVC, SignalR Server, each of which is described below:

    1. Dependencyinjection-Basic Dependency Injection management with default implementation
    2. EntityFramework-Data Access ORM Framework
    3. Identity-User authentication system
    4. Kruntime-Core runtime, project system, loader
    5. MVC-MVC framework that integrates MVC, Web APIs, Web pages features
    6. Signalr-server-Real-time interactive service

The open source code for all of the subproject's ASP. NET 5 can be https://github.com/aspnet/ found on the.

ASP. NET version number explanation 5

The new version of ASP, known as ASP. NET 5, is a framework for developing Web applications using the MVC architecture, which also provides the ability to develop restful services. Also, in the next release, the framework can 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 number of the new version of the. NET Framework, called Core50 , also called. NET .NET Core Core is a refactoring version of. NET, preserving only the minimized set of features in the original framework and, for other features and functionality, can be run as plug-ins in the form of NuGet downloads. This means that we can use it for standalone deployments in a variety of cloud environments. In addition, Microsoft will provide a cross-platform to .NET Core allow the ASP to be deployed on Mac and Unix/liunx servers. In addition .NET Core , the framework can be packaged and deployed together with the program, enabling the use of different versions on the same server .NET Core .

Also, be aware that it .NET Core does not include features such as Web Form, Windows form, WPF, WCF, Silverlight, System.Drawing, DataTable, and so on. In other words, if your program needs to use System.Drawing for thumbnail production, then there is no way to use it. A similar toolset can only be downloaded through the NuGet package. The tool can be used to find the current program and .NET Core the compatibility toolset.

4.5.2

4.5.2 is the version number of the current. NET Framework full-featured edition. You can use this version of the. NET to run ASP. 5, or even 4.5.1, using this version, you can use all the features of the entire. NET system, but not across platforms.

4.6

4.6 is the version number of the next version of the. NET Framework full-featured edition, which is also the next version number for. NET Core. You can run an ASP. NET 5 application on. NET 4.6, but the ASP. NET Core may not be compatible with the. The next version of ASP. NET Web forms is also 4.6, which will include enhancements such as asynchronous model binding, HTTP2, and getting started with the Roselyn compiler. Existing ASP. NET programs (Web Forms, MVC5, and previous versions, Web Pages) do not require any modifications to be run on. NET 4.6.

6

The MVC, Web API, Web pages three frameworks in ASP. 5 are merged into a single frame, collectively known as MVC6. The merge will remove duplicate features from the three frameworks, such as MVC and the two controllers in the Web API that only hold one. But the functionality of traditional MVC is preserved, such as model binding. However, it is said that Web pages will not be published in RTM, but will be published in the first update after RTM.

MVC6 introduces some new features, the most compelling feature being tag helpers and view components. Tag Helpers is a replacement for HTML helpers, and view components introduces the concept of WebControl in similar Web forms.

For example, the original view model definition is this:

@using (Html.BeginForm ("Register", "Account", FormMethod.Post, new {@class = "form-horizontal", role = "form"})) {@Ht ml. AntiForgeryToken ()<h4>create a new account.  </h4> <hr/> @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"}) </
                   
                    div> 
                    </div>  
                      
                      

In the new MVC6, we can use tag helper to define:

<FormAsp-controller="Account"asp-action="Register"Method="POST"class="Form-horizontal"role="Form" ><H4>create a new account.</H4><HR/><Divasp-validation-summary="Validationsummary.modelonly"class="Text-danger" ></Div><Divclass="Form-group" ><LabelAsp-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=< Span class= "Hljs-value" > "UserName" class= "Text-danger" > </span> </ div> </DIV>    

In this way, it is very convenient for front-end developers, because you can see the normal HTML structure.

View components solves the problem with the child action, for example, in many cases, we Html.Action implement the menu and label functions. Here is an example of a 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 also needs to respond to the view file, as shown in the following example:

@model string<h3>@Model</h3>

The calling code requires the Component.invoke method to use permissions, as shown in the following example:

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

There is also a Component.invokeasync method that can be used for asynchronous invocation. Refer to the View components chapter for detailed usage of the view components.

7

7 is the next version of the Entity Framework, although it is not part of an ASP. NET 5, but it is very much related. EF7 will be released along with the RTM version of ASP. NET 5, although it may be postponed, at least at that time there will be a basic ORM package that can run on. NET core, which does not include lazy loading, inheritance mapping, and is only suitable for SQL Server. If you are not running the MVC6 program on a cross-platform, you can continue to use EF6 in. NET 4.5.2 or 4.6.

10 changes in Asp.net5 and MVC6

In the new version of Asp.net5 and MVC6, there are a lot of changes, some are radical changes, such as at the bottom of the support of dependency injection technology, for the convenience of understanding, we listed here the most important 10 major changes in order to learn, as follows:

    1. The ASP. NET 5 is now cross-platform and can be run on Mac and Linux.
    2. There is no longer a Web Forms framework.
    3. Only C # is supported, not vb.net supported. (seems to have recently heard that the final version of vb.net and support)
    4. The new tag syntax, @Html. labelfor or Html.textboxfor Replace with a new syntax <label asp-for="Name"> or <input asp-for="Name" /> , for model binding.
    5. The new view Component, which defines the local content as a separate component for invocation, is very similar to the WebControl in Web Forms.
    6. Embrace the front-end technology with built-in Nodejs, NPM, Grunt, Bower technology.
    7. Model integration, integrating MVC and WEBAPI into one framework.
    8. Support Angularjs, help built-in ANGULARJS module, controller, directive, and factory templates.
    9. Supports dependency injection technology, has a native DI framework, and also supports third-party containers.
    10. Supports Xunit.net and discards the visual Studio Unit testing Framework.
Ide

VS2015: VS2015 not to mention, still tall, currently not only support Nodejs, Python development, but also support Android and iOS development.
Visual Studio Code: To be able to write C # programs on a Mac or Linux operating system, Microsoft has released a Visual studio Code lightweight editor that can use the above operating system, still tall, New features and features instant seconds to kill sublime text and brackets, detailed address please visit: https://code.visualstudio.com/.

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

Synchronization and recommendations

This article has been synchronized to the Catalog index: Interpreting ASP. & MVC6 Series

Introduction to ASP. 5

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.