ASP. NET5 Beta8 availability, asp. net5beta8

Source: Internet
Author: User
Tags web hosting

ASP. NET5 Beta8 availability, asp. net5beta8

ASP. NET5 beta8 now uses NuGet as a tool to upgrade to Visual Studio2015! This version greatly extends the range supported by the. NET core for OS X and Linux. You can now use cross-platform network, encryption, and globalization features! This press release also includes some good improvements to ASP. NET5, DNX, and Web tools. Let's take a look at how we get started with ASP. NET5 beta8.

New Features

The following is a summary of some new functions in ASP. NET5 beta8. For a complete list of new versions, see the beta8 release notes.

Change the IIS hosting Mode

We have made major updates to ASP. NET 5 IIS In beta8 hosting mode. Until it includes the β 7 integrated proteins, an ASP. NET 5 application running on IIS has held a composition named "Sun God", which is included in the Microsoft. AspNet. Server. IIS package. Use the existing System. Web Hosting mode to hook this component to promote DNX and CLR boot. This hook replaces running the application after it has started (but from the IIS perspective. This actually raises the "Sun God" second DNX host, which means it is included in its own logic related to locating, starting, and loading the run. This also means that the second group of logic is used to make services like runtime, and some DNX-level settings.

There are two different host models used for ASP. NET 5 that introduce a lot of complexity and contradictions that are difficult or impossible to solve. To solve this problem, we are suspending the "Sun God" IIS host. Hosting ASP. NET 5 applications in IIS will now be implemented using IIS HttpPlatformHandler configured to forward to the ASP. NET 5 redtail server. The HttpPlatformHandler is a local IIS module that needs to be installed by an administrator on the running server IIS (installation. It has also included updates to beta8 Network Tools on IIS. The initiator of the external application process managed by iis (dnx.exe) and the route from IIS request to the managed process.

Simplified models to a hosting option (but still supported in the same scenario) are used for developers to code and test less things. Other benefits of the new model include:

You do not need to run any managed code in the IIS program pool (you can literally configure it to not load CLR)
Existing ASP. NET Windows components do not need to be installed and run on Windows servers.
The existing ASP. NET 4.x module can be run in HttpPlatformHandler next to IIS. The ASP. NET 5 process is independent.
You can set environment variables according to the process, because HttpPlatformHandler supports. This will make it possible to configure something like ASP. NET 5 on the local IIS server.
Unified error handling on all server startup errors
Unified codes and Behaviors
Whether the. NET Framework (full CLR) is running, the supported app. config is self-managed or in IIS (even if it is used for. NET Framework compatibility without more web. config)
Uniform Service
The story of unified startup (No odd AspNetLoader. dll is in the bin folder)

You will find that the ASP. NET 5 Project template in Visual Studio has been updated, including the web. config file in the wwwroot folder of the application:

<configuration>  <system.webServer>    

In this web. config file, add HttpPlatformHandler to your application and the configured handler to forward the request to a DNX. The DNX_PATH environment variable set by the Visual Studio Controller points to the appropriate DNX version for your application.

When the process path of your published application in web. config is updated to the "network" command defined in your application. You can choose to use different commands to run DNU for release, instead of the -- iis Command Option.

For more information about these changes to the IIS hosting mode, see the relevant announcement.

ASP. NET 5 now has built-in support for localization. The new Localization support provides middleware to specify the thread that accesses the localized content in the correct culture and UI culture based on the request and mechanism.

Enable locating Add the required locating middleware to the application in your startup request pipeline:

App. UseRequestLocalization (option)

Request locating middleware uses a set of configured IRequestCultureProvider implementations to determine the requests to be trained. The built-in provider can use the Accept-Language header from the request, query the string value, or determine the cultivation from the cookie. You can also create and specify your IRequestCultureProvider.

Once the localized middleware is requested to determine the current culture, it sets it on the thread. The IStringLocalizer Service provides access to the content based on the current regional localization. Enable these localization services, such:

services.AddLocalization(options => options.ResourcesPath = "resources");

The ResourcePath specifies the path of the local resource relative to the application root directory. You can use the IStringLocalizerFactory service to create an IStringLocalizer-specific resource or directly request IStringLocalizer <T>.

By default, these services are implemented based on System. Resources. ResourceManager, which supports access based on the localized content of the resx file Affiliated Program. You can also provide your own implementations to obtain localized content from different sources, such as forming a database.

You can see that the full working samples of these localization functions are returned in localization.
Localization and MVC

MVC is built on ASP. NET 5 with new Localization support to make localized controllers and views. MVC introduces an additional service that is built on the core localization service.

To enable specific localization functions of MVC, you can add the following points when configuring the MVC service:

services    .AddMvc()    .AddViewLocalization(options => options.ResourcesPath = "Resources");

The IHtmlLocalizer service (with IHtmlLocalizerFactory) adds support for arguments for obtaining localized HTML strings and attribute encoding. You can use IHtmlLocalizer from your controller as follows:

Private IHtmlLocalizer <HomeController> SR;

private IHtmlLocalizer<HomeController> SR;public HomeController(IHtmlLocalizer<HomeController> localizer){    _localizer = localizer;}public ActionResult Index(){    ViewData.Message = SR["Localize me!"];    return View();}

The IViewLocalizer is an IHtmlLocalizer service that searches for resources based on the current view name. You can use the @ injection command to inject IViewLocalizer to your opinion:

@inject IViewLocalizer SR

In addition to the above, you can also view hidden files:

This is not allowed before Beta8.

For more information about beta8, visit the. NET Web development tool blog at Microsoft. NET:



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: 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.