In this post we are going to explore ASP.NET as open source web framework. First of all we will differentiate between .NET Framework(ASP.NET 4.6) & .NET Core(ASP.NET 5.0).

After that we will get basic overview ASP.NET Core 1.0 with creating a sample application.

 let’s get started:

 core_0

From above figure we can see that ASP.Net has two variation, one is .Net Framework which is now updated to version 4.6 or later by which we can create ASP.Net Web Form, MVC, Web API applications & another one is newly created open source WEB Framework(.Net Core) that can run & develop on cross platform (Windows, Linus, Mac).

If notice that .NET Core also has two variation that we can develop & run applications by targeting .NET Core 1.0 or .NET Framework, But .NET Core 1.0 doesn’t have all the features of .NET Framework.

Let’s differentiate both.

.Net Framework:

  • Developed and run on Windows Platform only.
  • Built on the .NET Framework runtime.
  • Supported (MVC, Web API & SignalR) Dependency Injection (DI).
  • MVC & Web Api Controller are separated.

 

.Net Core:

  • Open Source.
  • Developed and run on Cross Platform.
  • Built on the .NET Core runtime & also on .NET Framework.
  • Facility of dynamic compilation.
  • Built in Dependency Injection (DI).
  • MVC & Web Api Controller are unified, Inherited from same base class.
  • Smart tooling like(Bower, Grunt & Gulp).
  • Command-line tools.

 

Get started with .NET Core:  We will now get described how we can enabled .NET Core on our development PC.

We need to install Visual Studio 2015 & .NET Core SDK. I have installed Visual Studio 2015 Update 3* & .NET Core SDK for Windows.

Let’s create a new project with Visual Studio 2015 > File > New > Project

core_2

Click OK & choose a template in this case we are going to select an empty ASP.NET Core Template.

core_3

Finally we can see the welcome screen of sample app.

core_33

In Output tab we can see the package restored successfully. Let’s explore the app solution folder.

In Solution explorer there two main folder one is Solution Items & another one is SRC

core_6

In Solution Items there is a file named global.json which contained below code snippet which is actually settings of whole solution.

Code Explanation:

“projects”: [ “src”, “test” ] – is array type which specifies a list of project folder that are included in this solution.

Specifies SDK information along with SDK version, this has also specify another two properties – architecture & runtime.

Final Code Snippet after edit.

Runtime specifies as CLR = ASP.NET 4.6 runtime & as CORECLR = ASP.NET Core 1.0 runtime.

Let’s get explained about Project.json

 core_7

“dependencies”: It define which dependency package are required to run the application.

core_9

Additional properties are:

  1. Version
  2. Type
  3. Target
  4. Include
  5. Exclude
  6. suppressParent

 

“frameworks”: Defines target frameworks that will be built.

core_11

“buildOptions”: Define options that are passed to the compiler.

core_12

“runtimeOptions”: Manage server garbage collection at application runtime. The properties are:

  1. GC.Server
  2. GC.Concurrent

 

“publishOptions”: This define the file/folder to include/exclude to/from the output folder while publish the application.

core_10

“scripts”: Scripts is object type which specifies that scripts to run during build or publish the application.

core_8

 

Program.cs

In program class main method use WebHostBuilder to create web application host.

core_19

.UseKestrel() : Define the web server. ASP.NET Core supports hosting in IIS and IIS Express, and self-hosting scenarios using the Kestrel and WebListener HTTP servers.

Two different HTTP servers:

  1. AspNetCore.Server.Kestrel (AKA Kestrel, cross-platform)
  2. AspNetCore.Server.WebListener (AKA WebListener, Windows-only, preview)

 

.UseContentRoot(Directory.GetCurrentDirectory()) : Application base path that specifying path to root directory of the application.

The web root path defaults to <content root>/wwwroot, but you can specify a different location using the WebHostBuilder.

.UseIISIntegration() : For hosting in IIS and IIS Express.

.UseStartup<Startup>() : Specifies the Startup class.

core_20

.Build() : The Build and Run methods build the IWebHost that will host the app and start it listening for incoming HTTP requests.

core_21

.Run() :

core_22

That’s all for now, next part we will focus on ASP.Net MVC & Client Side Dependencies.

Hope this will help 🙂

5 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *