[Core]. Net Core Road (1) Hello World

Source: Internet
Author: User
Tags dotnet hosting

Directory

    • RELATED LINKS
    • dotnet command
    • VS Code Hello World
    • Web Hello World
    • Summarize

Actually, this article was written last month.

It's just that

However, do not forget the beginner's mind party must always

RELATED LINKS

Learn. NET Core

Http://asp.net/core

Down. NET Core
Https://www.microsoft.com/net/core

Doc. NET Core

Https://docs.asp.net/en/latest/getting-started.html

dotnet command

mkdir Hwapp--Create a directory Hwapp
CD Hwapp--Open Directory Hwapp
dotnet New-Create project (Program.cs + Project.json)

dotnet Restore--restoring dependency (Project.lock.json)
dotnet Build--Compile project (obj folder and Bin folder)
Dotnet Run-Runs the project (execution Bin\debug\projectname.dll)

Dotnet-h View Help

Command line run Hello World

Cmd

    • mkdir Hwapp--Create a directory Hwapp
    • CD Hwapp--Open Directory Hwapp
    • dotnet New-Create project (Program.cs + Project.json)
    • dotnet Restore--restoring dependency (Project.lock.json)
    • Dotnet Run-Runs the project (execution Bin\debug\projectname.dll)

VS Code Run Hello World
    • Continue with the example above to open the folder
    • Press F5 to select. NET Core (build. Vscode\launch.json)

    • Press the F5 prompt to configure (generate. Vscode\tasks.json)

The program in Launch.json needs to be configured above

"Program": "${workspaceroot}/bin/debug/<target-framework>/<project-name.dll>",

Change to the following ways

"Program": "${workspaceroot}/bin/debug/netcoreapp1.0/programname.dll",

It is important to note that it is not always useful to complete these pressed F5, confirming that C # debug is loaded

VS code in the lower right corner of the status bar will be prompted

CSharp extensions can also be manually installed

Ctrl + p:ext Install CSharp

By the end of the CSharp extension, F5 can run the program.

Ctrl + Shift + Y (Debug console):

Web Hello World

Try out the console version and experience a web version of

    • Project.json adding dependencies

"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final"

    • dotnet Restore (F1 + dotnet Restore)
    • New Startup class
Using microsoft.aspnetcore.builder;using microsoft.aspnetcore.hosting;using Microsoft.aspnetcore.http;namespace consoleapplication{public    class Startup    {public        void Configure (Iapplicationbuilder app)        {            app . Run (context =            {                return context. Response.writeasync ("Hello from ASP. core!");}}}    
    • Modify Program.cs
        public static void Main (string[] args)        {            Console.WriteLine ("Hello world!"); /using Microsoft.AspNetCore.Hosting;
            var host = new Webhostbuilder ()                        . Usekestrel ()                        . Usestartup<startup> ()                        . Build ();            Host. Run ();        }
    • F5 Access Http://localhost:5000/

Summarize

Disadvantages:

    • Need to download more from SDK + ext CSharp + restore
    • Debugging speed feeling is still relatively slow
    • Chrome Access Web address display cannot be accessed

Advantages:

    • Cross-platform
    • Lightweight

[Core]. Net Core Road (1) Hello World

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.