Write and run the first ASP. NET 5 Preview Web API program in Windows, previewapi

Source: Internet
Author: User

Write and run the first ASP. NET 5 Preview Web API program in Windows, previewapi

In July 21, 2015, Microsoft learned on the official Weibo of MSDN in China that Visual Studio 2015 was officially released.

The Visual Studio Community version was downloaded with an early taste.

In this first version, we can see ASP. NET 5 is still in the Preview status, of course for ASP. NET 5, Microsoft also provides a clear timetable, please read this article: Microsoft released ASP. NET 5 roadmap.

An ASP. NET 5 Preview Web API project was created with no wait, but the first battle was unfavorable. VS. NET prompted: "The dnx sdk version" dnx-clr-win-x86.1.0.0-beta5 "cannot be installed ". Since Google cannot access it, choose Bing.com.

After searching through Bing, some netizens suggested viewing ASP. NET 5 GitHub open-source HOME with detailed Tutorials.

The following two terms are explained ):

  • DNVM (. NET Version Manager). NET Version Manager
  • DNX (. NET Execution Environment). NET Execution Environment, including code for guiding and executing applications, including: Compiling System, SDK tool, native CLR (Public runtime) Host

According to the official Tutorials step by step:

1. If Visual Studio 2015 is installed, You can omit the installation of DNVM. I manually installed it myself and run the following command in CMD:

@powershell -NoProfile -ExecutionPolicy unrestricted -Command "&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}"

2. After installing DNVM, you can install DNX. A very simple command:

dnvm upgrade

When the drive letter is successful, you will be prompted to run the drive letter \ UserDir \. dnx \ runtimes \ dnx-clr-win-x86.1.0.0-beta5 \ bin is added to the PATH of the user variable; drive letter: \ UserDir \. add dnx \ runtimes \ dnx-clr-win-x86.1.0.0-beta5 \ bin to the PATH of the system variable.

After completing the preceding two steps, create an ASP. NET 5 Preview Web API project, OK, everything is normal (project reference can be loaded normally: DNX 4.51, DNX Core 5.0 )...

We will find a hosting. ini configuration file in the default project root directory, as shown below:

server=Microsoft.AspNet.Server.WebListenerserver.urls=http://localhost:5000

Server is used to specify the server on which the listener receives the request and finally responds to the request.

Server. urls is used to specify the listening address (URL, port number)

3. Run (for Windows Web apps)

First switch the directory to the root directory of the current project in CMD, and then run the following command:

dnx . web

If the server is successfully Started, we will see "Started.

Use the default URL to send a GET request, SUCCESS !!

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.