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:
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 . I have installed Visual Studio 2015 Update 3* & for Windows.
Let’s create a new project with Visual Studio 2015 > File > New > Project
Click OK & choose a template in this case we are going to select an empty ASP.NET Core Template.
Finally we can see the welcome screen of sample app.
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
In Solution Items there is a file named global.json which contained below code snippet which is actually settings of whole solution.
{ "projects": [ "src", "test" ], "sdk": { "version": "1.0.0-preview2-003121" } }
Code Explanation:
“projects”: [ “src”, “test” ] – is array type which specifies a list of project folder that are included in this solution.
"sdk": { "version": "1.0.0-preview2-003121" }
Specifies SDK information along with SDK version, this has also specify another two properties – architecture & runtime.
"version": { "type": "string", "description": "The version of the SDK to use." }, "architecture": { "enum": [ "x64", "x86" ], "description": "Specify which processor architecture to target." }, "runtime": { "enum": [ "clr", "coreclr" ], "description": "Chose which runtime to target." }
Final Code Snippet after edit.
{ "projects": [ "src", "test" ], "sdk": { "version": "1.0.0-preview2-003121", "architecture": "x64", "runtime": "coreclr" } }
Runtime specifies as CLR = ASP.NET 4.6 runtime & as CORECLR = ASP.NET Core 1.0 runtime.
Let’s get explained about Project.json
“dependencies”: It define which dependency package are required to run the application.
Additional properties are:
- Version
- Type
- Target
- Include
- Exclude
- suppressParent
“frameworks”: Defines target frameworks that will be built.
“buildOptions”: Define options that are passed to the compiler.
“runtimeOptions”: Manage server garbage collection at application runtime. The properties are:
- GC.Server
- GC.Concurrent
“publishOptions”: This define the file/folder to include/exclude to/from the output folder while publish the application.
“scripts”: Scripts is object type which specifies that scripts to run during build or publish the application.
Program.cs
In program class main method use WebHostBuilder to create web application host.
.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:
- AspNetCore.Server.Kestrel (AKA Kestrel, cross-platform)
- 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
.UseIISIntegration() : For hosting in IIS and IIS Express.
.UseStartup
.Build() : The Build and Run methods build the IWebHost that will host the app and start it listening for incoming HTTP requests.
.Run() :
That’s all for now, next part we will focus on ASP.Net MVC & Client Side Dependencies.
Hope this will help 🙂
Mokhlesur Rahman says:
Nice But needed full pack …………..
Shashangka Shekhar says:
yes brother i am working on it…:) stay tuned thanks 🙂
says:
Great!
Shashangka Shekhar says:
Thanks 🙂
mahfuzbappy says:
Wow … Its cool.
Thanks bro