ASP. 5 Series Tutorial (i): bribed new features

Source: Internet
Author: User
Tags http 2

Microsoft has recently released ASP. NET 5.0, the new feature requirement of this release stems from a large number of user feedback and requirements, such as flexible cross-platform runtime and autonomous deployment capabilities, so that the ASP. NET applications are no longer limited by IIS, Cloud-ready environment configuration lowers the threshold for cloud deployment, In addition, open source is undoubtedly a heavy-weight surprise. These changes will help you create Web applications that are easy to develop, deploy, maintain, and modern. Believe to see the above points as. NET programmer You can't wait to experience the new features of ASP. 5, let's look at these new features.

ASP. NET 5 is a framework for creating Web applications that is more concise and flexible than previous versions, and this release is a thoroughly optimized application development framework that allows you to easily deploy applications to the cloud or other platforms with the smallest modular components So make sure you're building complex solutions while maintaining flexibility.

ASP. NET 5 contains the following features:

• Flexible cross-platform runtime

• New HTTP Module request pipeline

· Cloud-ready Environment Configuration

• Unified programming model with MVC, Web APIs, and Web pages

• View change effects without recompiling

• Parallel version of the. NET Framework

• Autonomous deployment or IIS deployment capabilities

• New tools embedded in Visual Studio 2015

· GitHub Open Source

Applications developed with older versions can be run directly on ASP. NET 5 without any modifications. However, if you want to use the new ASP. NET 5 feature, you need to port the existing code to the new framework. The ASP. NET 5 and earlier versions of ASP are basically the same, so you just need to focus on new feature development, saving your code migration time.

The above summarizes the new features and enhancements of ASP. NET 5.

in this article we will focus on the following points:
    • Why do I redesign ASP.
    • Flexible cross-platform runtime requirements
    • Flexible deployment environment
    • Multi-framework version parallel use
    • Simplify dependency Management
    • Merging MVC, Web APIs, and Web pages
    • Enhanced HTTP Performance
    • Cloud-ready Deployment Capabilities
    • Integrated Dependency Injection
    • Open source
    • Provide an agile development environment
    • About Web Forms
    • Early version framework development application compatibility
Why do I redesign ASP.

Flexible cross-platform runtime requirements

The early versions of the. NET Framework have been installed as a single, comprehensive whole, with each new version containing new features and almost all of the early features, with few deletions, which inevitably result in the volume growth of the Framework. This mode ensures that Windows systems with the new framework installed can be compatible with all previous versions of. NET applications, but also means that each application will run on a large, redundant framework, even though many features are not used in the actual project.

Believe in each person. NET programmers have experienced the following embarrassing decision scenarios: When receiving notifications from the framework for an update release, it is time to abandon the flexibility of using new features to keep apps or to use new features to make your framework bigger!

In order to cope with the above scenario. ASP. NET 5 provides three runtimes, which you can choose flexibly depending on your needs:

1. full-featured . NET CLR
The full-featured. NET CLR is the default runtime state of Visual Studio engineering. It provides all of the APIs and is the best choice for keeping your application backwards compatible.

2. Core CLR (cloud-optimized Runtime)
The core CLR is a streamlined, fully modular runtime. This CLR has been redesigned as a component to make it easy for you to include only the. NET attributes that are actually used in your project. The component is added as a nuget package. Once the reference is complete, your app relies only on the required functionality. By decomposing the runtime into components, we can change each component more quickly because each component has a self-updating mechanism. The core CLR is only 11M in size , and the full-featured CLR relative to 200M will undoubtedly make the application more portable. The core CLR can be deployed along with the application and different core CLR can run in parallel.

3. Cross-platform CLR
Microsoft will publish a cross-platform runtime for Linux and Mac OS X releases. It means your. NET applications have the ability to run on Mac and Linux devices. Microsoft will work with the Mono community to complete this new feature. Before publishing, you can use the mono CLR for cross-platform development.

The new Visual Studio Project uses the full-featured. NET CLR By default and can be changed to the core CLR on the project Properties page.

Flexible deployment Capabilities

ASP. NET 5 allows deployment to be applied to IIS or isolated from IIS, and when the target Framework is set to the core CLR, the dependencies in the deployment package can be used to deploy the app. As a result, your app self-contained and doesn't depend on the full-featured. NET version. The app can run apps on any device and platform.

That's right. NET platform developers is no doubt a surprise, deployment of applications is not limited to IIS, of course, Microsoft still recommends that you use IIS to deploy the application, but if you need to deploy the application on a platform that is not compatible with IIS, you can use this new feature to operate.

Later in the article we will publish how to create an MVC6 app that does not depend on IIS, so please look forward to it.

Multiple Versions . NET Parallel Use

Earlier versions of the. NET Framework, you will always be faced with the choice of whether to update the version, on the one hand you want to use the updated features, on the other hand you will be the old version development of the project can be smoothly migrated to the new version of the. NET Framework and feel tangled.

Microsoft has improved these issues in ASP. NET 5. With the core CLR premise, you can define dependencies within the deployment package, so you can specify for each application. NET version. Legacy apps can run smoothly, and you can also develop apps with new versions. Therefore, in ASP. NET 5, multiple versions of the. NET applications are parallel.

Simplify dependency Management

ASP. NET 5 introduces a new, lightweight dependency management mechanism. Instead of adding references to your app, you'll use the reference NuGet package instead. You can add NuGet packages through the NuGet Package Manager, or you can edit the include NuGet package list and version information JSON file (Project.json) to implement the reference. The Project.json file is used to enumerate the NuGet-related information used by your app, and to add additional references, add them directly to the JSON file.

In Visual Studio 2015, you can quickly add NuGet packages based on smart hints.

The Project.json file contains only NuGet packages that are added directly to the project. If you add a package that references an outside file, such a dependency will simply be loaded and not displayed in the Project.json file. This mechanism makes Project.json files easy to manage.

The JSON format file allows you to easily manage references without the installation of Visual Studio. Of course, you can use any text editor to open and edit Project.json.

merging MVC, Web APIs, and Web pages

In earlier versions, MVC, Web APIs, and Web pages had been using different ways to achieve the same functionality, which could be said to be the same. For example, MVC and the Web API both provide routing, but the MVC routing class is in the System.Web.Mvc.Routing namespace, and similar classes in the Web API are in the System.Web.Http.Routing namespace. For one more example, both Web pages and MVC have razor syntax, but they are still included in different nuget packages with the same functionality.

in ASP. NET 5, the MVC, Web API and and Web pages will be integrated into the same framework-mvc 6. This means that the repetitive function modules are removed, making it easier to develop applications.

In the preview version, the MVC and Web API was first incorporated into MVC 6. The Web page will be added later in subsequent release builds.

Enhanced HTTP Performance

ASP. NET 5 provides a refined, fast HTTP request pipeline that allows you to add only the components you need, and the application will have better throughput by mitigating the overhead of the pipeline.

Cloud deployment Capabilities

When you create a new ASP. NET 5 project, the project already has a structure that can be easily deployed to the cloud by default. Visual Studio 2015 provides a new environment configuration system in place of the Web. config file. The new system allows you to store key-value pairs using a variety of file types, such as JSON, XML, or or environment variables, so you can easily specify values or get them in any environment.

At the same time, ASP. NET 5 provides tools to detect and track deployed cloud application issues.

Integrated Dependency Injection

Dependency injection is built into ASP. NET 5. You can register dependencies using the IOC container. The injection of dependency facilitates the provision of the correct service environment.

Open Source

Asp. NET source has been posted to GitHub. Not only the current version of the source code, Microsoft is also committed to update the source on GitHub, you can immediately see the changes to the ASP, you can download and commit changes to GitHub.

This will help you understand the ASP and the technical trends, and you can customize your own ASP.

Provide an agile development environment

Visual Studio provides a lightweight ASP. NET development environment. No need to recompile the project, just save the change code, you can view the latest results in the browser.

The code that you changed can be in a Web project or in a class library that is referenced by the current Web project.

Visual Studio uses the Roslyn compiler to allow dynamic compilation. Make sure you have a complete, powerful compilation framework, and have a development experience that tends to explain the language.

Each visual Studio user interface has a corresponding script, so you can easily switch between the UI interface and the script.

Finally, you can edit the ASP. NET 5 project using a different code editor.

about Web Forms

Microsoft has been working to provide users with new features to improve the development experience, and you can still develop Web Forms applications and add the following new features to Web Forms 4.6:

    • HTTP 2
    • Asynchronous binding pattern
    • Roslyn CodeDOM Compiler

Previous versions of WEB Forms applications developed without any changes can be run directly under the IIS. NET 4.6 Framework. However, the new features of the ASP. NET 5 core CLR cannot be used.

For example, there are applications that are currently developed using Web Forms, MVC 5, Web API 2, SignalR 2, Web Pages 3, or Entity Framework 6, and you only need to set the current runtime version to run full-featured, without any code-level modifications. Run in Sp.net 5. However, the core CRL is a new feature of ASP. NET 5, and if you want to apply the functionality of the runtime, you need to make some changes. Microsoft provides API portability Analyzer tool to determine if the current application can use the core CRL. The tool can also analyze which platforms the current app can run on and what prevents it from running on a specific platform. You will also be prompted for the changes you need and what new interfaces to use to replace them.

MVC 6 and SignalR 3 applications use new HTTP pipelines, so they cannot be compatible with apps that use the System.Web interface. If you need to upgrade an existing application to MVC 6 or SignalR 3, you must create a new project using Visual Studio 2015 and then import the original project, and you will need to modify the unsupported code snippet during the import process.

ASP. 5 Series Tutorial (i): bribed new features

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.