Skip to main content
Getting started with ASP.NET Core MVC and Visual Studio

Getting started with ASP.NET Core MVC and Visual Studio

ASP.NET Core is a significant redesign of ASP.NET. With the help of this post, we will be guiding you to create a brand new ASP.NET Core MVC web application from scratch.

Get started with ASP.NET Core MVC and Visual Studio #aspnetcore #visualstudio #aspnetcoremvc Click To Tweet

From the Visual Studio Start page, click New Project. Alternatively, you can use the File menu to create a new project. Navigate to File –> New –> Project.

Complete the New Project dialog as shown below:

  1. In the left pane, click on .NET Core
  2. In the center pane, select ASP.NET Core Web Application (.NET Core)
  3. Name the project “MyFirstASPNETCoreWebApp” or any name you wish to call your app.
  4. Click OK

aspnet-core-web-application

Complete the New ASP.NET Core Web Application(.NET Core) – MyFirstASPNETCoreWebApp dialog:

  1. Select Web Application
  2. Uncheck Host in the cloud. By default, this option is checked.
  3. Click OK.

aspnet-core-web-application-template


Solution Structure

Screenshot below depicts the Solution Structure for ASP.NET MCV Core application.

Have a close watch at the highlighted file(s)/folder(s):

aspnet-core-web-application-solution-structure

New Skills, New You: Transform your career in 2016 with Coursera

wwwroot

Contains all the css, images, js & lib files which are referenced in the entire project.

global.json

This files has the details of projects/sources and packages.

{
 "projects": [ "src", "test" ],
 "sdk": {
 "version": "1.0.0-preview2-003121"
 }
}

For more information refer – global.json details

project.json

This file contains entire information related to the current project. For instance, dependencies, buildOptions, publishOptions, frameworks any many more. For more information, you can refer – project.json details

{
 "dependencies": {
 "Microsoft.NETCore.App": {
 "version": "1.0.0",
 "type": "platform"
 },
 "Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
 "Microsoft.AspNetCore.Diagnostics": "1.0.0",
 "Microsoft.AspNetCore.Mvc": "1.0.0",
 "Microsoft.AspNetCore.Razor.Tools": {
 "version": "1.0.0-preview2-final",
 "type": "build"
 },
 "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
 "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
 "Microsoft.AspNetCore.StaticFiles": "1.0.0",
 "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
 "Microsoft.Extensions.Configuration.Json": "1.0.0",
 "Microsoft.Extensions.Logging": "1.0.0",
 "Microsoft.Extensions.Logging.Console": "1.0.0",
 "Microsoft.Extensions.Logging.Debug": "1.0.0",
 "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
 "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0"
 },

"tools": {
 "BundlerMinifier.Core": "2.0.238",
 "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
 "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
 },

"frameworks": {
 "netcoreapp1.0": {
 "imports": [
 "dotnet5.6",
 "portable-net45+win8"
 ]
 }
 },

"buildOptions": {
 "emitEntryPoint": true,
 "preserveCompilationContext": true
 },

"runtimeOptions": {
 "configProperties": {
 "System.GC.Server": true
 }
 },

"publishOptions": {
 "include": [
 "wwwroot",
 "Views",
 "Areas/**/Views",
 "appsettings.json",
 "web.config"
 ]
 },

"scripts": {
 "prepublish": [ "bower install", "dotnet bundle" ],
 "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
 }
}

Visual Studio used a default template for the MVC project you just created, so you have a working app right now just by entering a project name and selecting a few options. We can call this as a simple “Hello World” project, and it’s a good place to start.

Press F5 key from your keyboard to run the app in debug mode or Ctrl + F5 in non-debug mode.

The default template gives you working Home, Contact and About links.

my-first-aspnet-core-web-application

Hurrah! We got our very first ASP.NET Core MVC web app up and running that too within few minutes without writing a single line of code.

That’s the beautify of the template. Microsoft developers have made our lives pretty easy by doing all the complex work behind the scene for running this web application.

Hope you enjoyed this post, in the next ASP.NET Core MVC post we’ll learn about MVC and start writing some code.

Master Computer Science on Coursera

What do you think?

Dear Readers,
Questions or suggestions are welcome. Feel free to email us or put your thoughts as comments below. We would love to hear from you. In addition to that, if you found this post useful then please share along with your friends and help them to learn.

Happy Coding!

Was this article worth reading? Share it with fellow developers too.

DotNetCrunch

DotNetCrunch is a popular blog for latest Microsoft® technologies which is aimed for beginners and intermediate level professionals.

  • Great start on .NET core. Keep posting more on it.

    • Thanks @disqus_mlyjxQtbjF:disqus. We will surely try to keep our readers updated on latest technology trends of .NET.