More About ASP.NET MVC 6 – Windows ASP.NET Core Hosting 2019 | Review and Comparison
 

What You Need to Know About ASP.NET Core 1.0 MVC 6

MVC 6  is built on top of ASP.NET Core 1.0 and  merges several framework into a unified programming model. MVC 6 is made up of MVC, Web API , and  Web Pages.

image_1

What’s New in ASP.NET MVC 6

  • Built on-top of  ASP.NET Core 1.0( Yes !) .
  • Supports the .NET Core 1.0
  • Tag Helpers (read my next blog post): Tag Helpers enable server-side code to participate in creating and rendering HTML elements in Razor files. And can be used as alternative to HTML helpers.
  • Runs on IIS or Self hosted servers using Kestrel.
  • Kestrel is an open source  cross-platform web server based on libuv, a cross-platform asynchronous I/O library.
  • Web UI +  Web API
  • One set of concepts : This means you have use one controller,one action , one filter etc for your application.
  • Deep Integration(DI):  This means you can inject services into your controllers , views, and filters.

ASP.NET Core 1.0 Project Structure 

project.json File

Open your new web application in Visual Studio 2o15 or  Visual Studio Code and open your project.json file.  VS 2015 uses project.json to reference dependencies, run commands, target frameworks, identify files to be excluded when publishing your application.

 

{
  "userSecretsId": "aspnet5-GeekQuiz3-f82c01b9-aeca-4ceb-aff8-9e212ff5f450",
  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
    "Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
    "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
    "Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final"
  },

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel",
    "ef": "EntityFramework.Commands"
  },

  "frameworks": {
    "dnx451": { },
    "dnxcore50": { }
  },

  "exclude": [
    "wwwroot",
    "node_modules"
  ],
  "publishExclude": [
    "**.user",
    "**.vspscc"
  ],
  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
  }
}

Dependencies : values located in this section refer to installed NuGet packages.

Commands: ASP.NET Core 1.0 supports command line tools. This section allows for you to configure commands that can be run in the command line. Project.json file. For example when running dnx.exe you can pass the name of a command to execute it. In the code  below you could run “dnx . web” to self host the app on Windows or “dnx . kestrel” to run your app on OS X/Linux.

 

{
  "commands": {
    "web": "Microsoft.AspNet.Hosting server.name=Microsoft.AspNet.Server.WebListener server.urls=http://localhost:5001",
    "kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:5004",
    "ef": "EntityFramework.Commands"
  },

Frameworks: this section is used to target frameworks that will be built, and dependencies required for configuration. For example dnx451 target the desktop and dnxcore50 targets Core CLR.

exclude & publishExclude: both these sections as the name suggests identifies files, folders and content potions of the project that need to be excluded from the build and publishing the site.

global.json

Is used to configure the solution as whole, and is made up of project and sdk.

 

{
  "projects": [ "src", "test" ],
  "sdk": {
    "version": "1.0.0-rc1-update1"
  }
}

projects  designates which folder contains source code, and sdk specifies the version of dnx that VS 2105 will use for your solution.

wwwroot folder

Is the root of  your web application when running on a webserver,  This folder consist of asset that your web app will directly serve to the client , and includes CSS, Images, HTML, libraries and JavaScript files. Note all your code files ( C#  and Razor) should exist outside this folder.

image_2

Client & Server  Side Dependency Management

image_3image_4

[crp]