. NET Cross-platform: Run the ASP. DNX 5 Sample Program on Ubuntu with your own compiled

Source: Internet
Author: User

After successfully compiling DNX on Linux Ubuntu, the dnx-coreclr-linux-x64/and dnx-mono/2 folders are generated in the artifacts/build/folder , the former is based on the CoreCLR Dnx, which is based on Mono's dnx.

In this blog post we will run the ASP. NET 5 sample program using CORECLR-based DNX, and DNX and everything it needs are in the dnx-coreclr-linux-x64/bin/folder, so you can run an ASP with the following command. NET 5 applications.

/data/git/dnx/artifacts/build/dnx-coreclr-linux-x64/bin/dnx. Kestrel

Let's actually experience the three types (CONSOLE/WEB/MVC) of the ASP. NET 5 sample program. The sample program is from github.com/aspnet/home/.

A

The first sample program is a ConsoleApp (ASP. NET 5 Console application)

using System;  Public class program{    publicstaticvoid  Main ()    {        Console.WriteLine (  "HelloWorld");}    }

Run the ASP. NET 5 Console application with the following command (no Web server required):

Cd/data/git/home/samples/latest/consoleappdnu restore/data/git/dnx/artifacts/build/dnx-coreclr-linux-x64/bin/ Dnx. Run

Run successfully! The results are as follows:

Hello World

Two

The second example program is Helloweb (an ASP. NET 5 Web application that does not use MVC)

using Microsoft.AspNet.Builder; namespace helloweb{    publicclass  Startup    {        publicvoid  Configure (Iapplicationbuilder app)        {            app. Usestaticfiles ();            App. Usewelcomepage ();     }}}

Run the program with the following command (requires a Web server with Kestrel)

Cd/data/git/home/samples/latest/helloweb
Dnu Restore/data/git/dnx/artifacts/build/dnx-coreclr-linux-x64/bin/dnx. Kestrel

Failed to run! The following error occurred:

System.InvalidOperationException:Unable to load LIBUV. Make sure LIBUV is installed and available as Libuv.so.1

This is because the LIBUV is not installed on the Unbuntu, and Kestrel is based on LIBUV. So to install LIBUV first, install the following command:

git clone https://github.com/libuv/libuv.gitsh autogen.sh./configuremakemake installsudo ln-s/usr/local/lib/ Libuv.so/usr/lib/libuv.so.1

Continue to use DNX. Kestrel Command Run, this run successfully!

#/DATA/GIT/DNX/ARTIFACTS/BUILD/DNX-CORECLR-LINUX-X64/BIN/DNX. kestrelstarted

Then access the hostname: port number through the browser and you will see the default page for the Helloweb output:

Three

The second sample program is HELLOMVC (an example of an MVC 5-based program)

 using   Microsoft.AspNet.Builder;  using   Microsoft.Framework.DependencyInjection;  namespace   hellomvc{ class   Startup { public  void   Configureservices (iservicecollection services) {services.        Addmvc ();  public  void   Configure (Iapplicationbuilder app) {app.            Useerrorpage (); App.            Usemvcwithdefaultroute (); App.        Usewelcomepage (); }    }}

Run the ASP. NET 5 MVC sample application with the following command:

Cd/data/git/home/samples/latest/hellomvcdnu Restore/data/git/dnx/artifacts/build/dnx-coreclr-linux-x64/bin/dnx. Kestrel

Run successfully!

#/DATA/GIT/DNX/ARTIFACTS/BUILD/DNX-CORECLR-LINUX-X64/BIN/DNX. kestrelstarted

Then, with a browser access, you can see the pages of the MVC output:

Three ASP. 5 Sample programs run successfully!

While these three sample programs are just trivial little toys, they run on the latest. NET cross-platform Troika Coreclr/corefx/dnx, which can actually be realized. NET cross-platform is stepping forward. And based on the micro-step of. NET cross-platform, we can try to run some very simple sites on it.

. NET Cross-platform: Run the ASP. DNX 5 Sample Program on Ubuntu with your own compiled

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.