Your First ASP 5 application on a MAC

Source: Internet
Author: User
Tags using git

Your First ASP 5 application on a MAC

by Daniel Roth, Steve Smith, Rick Anderson

ASP. 5 is cross-platform; You can develop and run web apps on Mac OS X, Linux and Windows. This article would show you what to write your first ASP. 5 application on a Mac.

Sections:

    • Setting Up Your development environment
    • Scaffolding Applications Using Yeoman
    • Developing ASP. Applications on a Mac with Visual Studio Code
    • Running locally Using Kestrel
    • Publishing to Azure
    • Additional Resources
Setting Up Your development environment
    • Install ASP. Your Mac with OS X
    • Check which DNX version you has active by runningdnvm list
Scaffolding Applications Using Yeoman

Follow the instruction in Building Projects with Yeoman to create an MVC 6 project.

Developing ASP. Applications on a Mac with Visual Studio Code
    • Start Visual Studio Code

Note

If Visual Studio Code is not a installed, see Install ASP. Your Mac with OS x.

    • Tap File > Open and navigate to your ASP

From a terminal/bash prompt, run to dnu restore restore the project ' s dependencies. Alternately, you can enter and then command shift p type as >d shown:

This would allow you to run commands directly from within Visual Studio Code, including and any dnx restore commands defined in th E project.json file.

At the this point, you should is able to the host and browse to the this simple ASP. NET Web application, which we'll see in a moment.

This empty project template simply displays "Hello world!". Open in Visual Studio Code to see how this is Startup.cs configured:

If This is the your first time using Visual Studio code (or just code for short), note that it provides a very stream Lined, fast, clean interface for quickly working with files, while still providing tooling to make writing code extremely productive.

In the left navigation bar, there is four icons, and representing four viewlets:

    • Explore
    • Search
    • Git
    • Debug

The Explore Viewlet allows you and quickly navigate within the folder system, as well as easily see the files you are Curre ntly working with. IT displays a badge to indicate whether any files has unsaved changes, and new folders and files can easily be created (w Ithout has to open a separate dialog window). You can easily Save any from a menu option that appears on mouse over, as well.

The search Viewlet allows quickly search within the folder structure, searching filenames as well as contents.

Code 'll integrate with Git if it's installed on your system. You can easily initialize a new repository, make commits, and push changes from the Git viewlet.

The Debug Viewlet supports interactive debugging of applications. Currently only node. js and mono applications is supported by the interactive debugger.

Finally, Code ' s editor has a ton of great features. Should note right away that several using statements is underlined, because Code has determined they is not Necessar Y. Note that classes and methods also display how many references there is in the project to them. If you ' re coming from Visual Studio, Code includes many of the keyboard shortcuts you ' re used to, such as to command k c comment A block of code, and to command k u uncomment.

Running locally Using Kestrel

The sample is configured-Kestrel for the Web server. You can see it configured in theproject.json file, where it is specified as a dependency and as a command.

 1 2 3 4 5 6 7 8 910111213141516171819202122232 42526272829303132 
 {"version": "1.0.0-*", "Usersecretsid": "Aspnet5-mywebapp-a1b0 7c55-6f20-4aaf-9852-9c964160a00c "," compilationoptions ": {" Emitentrypoint ": true}," tooling ": {" Defaultna Mespace ":" MyWebApp "}," dependencies ": {" entityframework.commands ":" 7.0.0-rc1-final ",//dependencies Delet Ed for brevity.  "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final"}, "commands": { "we   B ":" Microsoft.AspNet.Server.Kestrel "," EF ":" Entityframework.commands "},//Markup deleted for brevity.   "Scripts": {"prepublish": ["NPM Install", "Bower Install", "Gulp clean", "Gulp min"] } }
    • Run the dnx web command to launch the app
    • Navigate to localhost:5000 :
    • To stop the Web server enter Ctrl+C .
Publishing to Azure

Once you ' ve developed your application, you can easily use the Git integration built into Visual Studio Code to push Updat Es to production, hosted on Microsoft Azure.

Initialize Git

Initialize Git in the folder you ' re working in. Tap on the Git viewlet and click the Initialize Git repository button.

ADD a COMMIT message and tap Enter or tap the checkmark icon to commit the staged files.

GIT is tracking changes, so if you do a update to a file, the Git viewlet would display the files that has changed sinc E your last commit.

Initialize Azure Website

You can deploy to Azure Web Apps directly using Git.

    • Create a new Web App in Azure. If you don't have an Azure account, you can create a free trial.
    • Configure the Web App in Azure to support continuous deployment using Git.

Record the Git URL for the Web App from the Azure Portal:

    • In a Terminal windows, add a remote named with the azure Git URL for you noted previously.

      • git remote add azure https://[email protected]:443/rickmac.git
    • Push to master.

      • git push azure masterTo deploy.

    • Browse to the newly deployed web App.

Additional Resources
    • Visual Studio Code
    • Building Projects with Yeoman
    • ASP. Fundamentals

Your First ASP 5 application on a MAC

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.