Experience precompiled MVC Razor view in ASP. NET Core 1.1

Source: Internet
Author: User
Tags dotnet

This is a trick learned from the official release of ASP. NET Core 1.1 to compile the Razor view as a. dll file when Dontet publish.

You need to add the following configuration in Project.json:

1) in "Dependencies", add:

"Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Design": "1.1.0-preview4-final"

2) in "Tools" add:

"Tools": {    "Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Tools": "1.1.0-preview4-final"}

3) in "Scripts", add:

"Scripts": {    "postpublish": "Dotnet razor-precompile--configuration%publish:configuration%--framework%publish : targetframework%--output-path%publish:outputpath%%publish:projectpath% "}

The Razor view in the ASP. NET Core project is then compiled when you run the dotnet Publish command:

Running Razor View precompilation. Precompiled views emitted to/data/aboutus/bin/release/netcoreapp1.1/ubuntu.14.04-x64/publish/ AboutUs.PrecompiledViews.dll.Successfully compiled Razor views in 12734ms.

The MVC Razor view is compiled into a AboutUs.PrecompiledViews.dll file that requires only this DLL file when running the site and does not require the. cshtml view file.

Experience precompiled MVC Razor view in ASP. NET Core 1.1

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.