Skip to content

A sample Visual Studio Code Web Application that uses .Net Core

Notifications You must be signed in to change notification settings

cmiles74/VSCode-Sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
Christopher M. Miles
Sep 19, 2018
1d2e5ec · Sep 19, 2018

History

45 Commits
Jan 12, 2018
Feb 2, 2017
Nov 23, 2016
Nov 23, 2016
Sep 16, 2016
Nov 23, 2016
Nov 27, 2016
Feb 2, 2017
Sep 16, 2016
Aug 27, 2018
Mar 8, 2017
Sep 16, 2016
Sep 16, 2016
Jan 12, 2018
Aug 27, 2018
Jan 12, 2018
Sep 16, 2016
Sep 16, 2016
Sep 19, 2018
Jan 12, 2018
Sep 16, 2016

Repository files navigation

Working Sample ASP.Net Core with Web API Application

This project provides a sample ASP.Net Core web application with Web API that will build and run on .Net Core 1.0.1. It will server up a sample single page web application that uses Bootstrap and React. The general idea is that you would copy the repository and use it as a basis for your own project.

This sample project pairs well with my Visual Studio Code (VS Code) Docker image. That image includes everything you need to get started and it's all setup and sorted out for you. This project includes VSCode tasks and launch targets to make development easier.

NOTE: This project hasn't been updated in a while and is pretty out-of-date.

Installing Project Dependencies

First off, you need .Net Core 1.0.1 or better installed. Installation is different depending on the operating system you are using, check out these pages for more information. If you are using Visual Studio, you might be all set already.

This application uses NodeJS and Gulp to build the client-site application. If you don't have NodeJS installed, you can download it from the Node.js website, I recommend using the "LTS" version.

Node.js comes with the Node Package Manager (NPM). To install the Grunt tool, open a terminal session (in VS Code, choose "Integrated Terminal" from under the "View" menu, in Visual Studio open up a new command prompt window and navigate into your project folder) and type

npm install -g grunt-cli

After install Grunt on Windows, you may have to open a new terminal session before you can actually use it.

Building the Application

To build the application, open up a terminal session and type...

dotnet build

If you are using Visual Studio, you may simply choose "Build Solution" from under the "Build" menu.

To build the client side application, type the following into a terminal session...

gulp build

Or, in VS Code, choose the "Command Palette" from under the "View" and type "build" to choose "Run Build Task", or press Ctrl-Shift-B.

The client side application will build into the "wwwroot" folder so that it can be served up by the server side application.

Setup the Database

The application uses a SQLite database to store it's data, it's stored on-disk in bin\Debug\netcoreapp1.0. After building the application, apply the migrations to create this database.

dotnet ef database update

Running the Application

To run the server side application, open up a terminal session and type...

dotnet run

In VS Code, you can select "Debug" from under the "View" menu and choose the ".Net Core Launch (web)" target. This will also attempt to open the application in your default web browser.

In both cases, the server side application will build (if necessary) and then start running. The server application will serve the static files in the "wwwroot" folder, this contains the client side application.

That's all well and good, but not much fun from a development point-of-view. To develop interactively, you can type the following in your terminal session:

gulp run

In VS Code, you can invoke the "Command Palette" and type "run" to select the "Run Task" option and then choose "run".

Stopping the Application in Visual Studio Code

To stop the running application task in VS Code, you can invoke the "Command Palette" and type "term" to select "Tasks: Terminate Running Task".

About

A sample Visual Studio Code Web Application that uses .Net Core

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published