ASP. NET 5 (4)-ASP. net mvc 6, asp. netmvc

Source: Internet
Author: User
Tags ruby on rails

Step by step learning ASP. NET 5 (4)-ASP. net mvc 6, asp. netmvc

Forward: Microsoft MVP Lu Jianhui's article, hoping to help you. Original article: http://blog.csdn.net/kinfey/article/details/44459625

Editor's note: The article written last night does not review csdn. This is no wonder, but I am too busy to help. Continue to share. Today we will talk about ASP. net mvc 6.

I like Ruby On Rails, which is better than the configuration framework. In. NET, ASP. NET MVC and Java have Play! The Framework. ASP. net mvc version is updated every year and never disappoint you. Now let's take a look at ASP. net mvc 6 changes, the previous article has explained the basic configuration and changes (step by step learning ASP. NET 5 (III)-understand the new Web structure). Let's take a look at several features of MVC 6 today.

1. Unified MVC and WebAPI Controller

In previous versions, you must inherit from System-based APIs when defining webapis. web. http. apiController. If it is a general page Controller, it must inherit from System. web. MVC. controller. In the new ASP. net mvc 6, Microsoft unifies MVC and WebAPI, both of which are inherited from Microsoft. AspNet. Mvc. Controller.


In ASP. net mvc 6 Controller, each Action returns an IActionResult interface, which returns the page or data based on the situation. In MVC 6, WebAPI and page Controller can use the same routing rules. You can also set routing rules through public methods or attribute labels.

 

2. Tag Helper (https://github.com/DamianEdwards/TagHelperStarterWeb)

When developing ASP. net mvc, you will be impressed with the amazing Tag helper. The following code is quite familiar.

Although convenient, it does not greatly damage the readability of html. The new version provides better readability and is closer to html.

 

3. View comatrix

This is a new sub-view that replaces the original SubController. (This function is rarely used.) I understand that it is better to make good use of page components. It can truly achieve local response. (You can refer to here: http://www.asp.net/vnext/overview/aspnet-vnext/vc)

 

4. Dependency Injection

ASP. NET 5 already has dependency injection, so you don't need to use third-party IoC (if you need to do so, you can also do it through a third-party method, but it is very troublesome at this stage ). Dependency injection is based on Microsoft. Framework. DependencyInjection. You need to configure it in the ConfigureServices method in Startup. cs.

ASP. net mvc 6 improves functions on the original basis, optimizes the Razor structure of the front-end page, and makes development and maintenance easier and faster. I personally prefer to unify WebAPI and general page Controller, and add the dependency injection function. What about you?

In addition, due to busy work, the article will continue on Sunday. I hope you will miss me.

 

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.