Introduction to ASP.NET Core - Basic Introduction with Visual Studio 2015 and 2017

In this blog, we will come to know about the open source framework given by Microsoft i.e. ASP.Net Core.

What is ASP.NET Core?

The asp.net core is a new open source framework introduced by Microsoft. Originally it was called ASP.Net 5 but later renamed to ASP.Net Core and released the first version of ASP.Net Core in year 2016. Next version i.e. ASP.Net Core 2.0 was released in year 2017.

ASP.Net Core is a cross-platform open source framework for building modern applications including cloud-based development.

ASP.Net Core is designed to support client-side frameworks like KnockoutJS, Angular JS and Bootstrap.

ASP.Net core has various architectural changes which make it a great framework for a developer. You can say it's a new version of .net.


From .Net version 1.1 to .Net 4.6 there are numerous features which were added and yes those features have been used widely in industry. But there was a limitation with .Net framework.
Application developed in .Net framework can be hosted in Windows environment only. Means .Net framework given by Microsoft can run within Windows OS given by Microsoft.

So, people from Linux or Mac background cannot utilize those .Net based application.

To open this boundary Microsoft introduces its open source framework and named it as .Net Core.
.Net Core provides a new way to develop an application and gives you the flexibility to develop application in your favorite environment on your favorite tool.

You can say that, .Net core is a cross-platform implementation of .Net framework.

Advantages of ASP.Net Core?

  • It is a framework to build web applications 
  • It is open source 
  • Deploy .Net core application to on-premises or to the cloud
  • Build and run the application on Windows, MAC and Linux 
  • A cloud-ready environment 
  • Ability to host in IIS or self-host
  • Use of Docker Containers
  • Implements Microservice Architecture
ASP.Net core apps can run on cross-platform such as Windows, Mac, Linux. So how can someone choose between .Net core and ASP.Net Framework.

Go for .Net core, if :

1. You are developing a cross-platform application.
2. You are looking for a high performance and scalable system.

Go for ASP.Net framework, if:

1. You are working on an environment that does not support .NET core.
2. NuGet packages not available for .NET Core.

.Net Core Tools

1. Visual Studio 2015/2017
2. Command Line Interface 

How to start development with .Net Core in Visual Studio 2015?

If you are using VS 2017 you will get .Net Core in installed template. And if you are using VS 2015 then you need Update 3 of VS 2015.
Follow below steps to update Visual Studio 2015 to start development with ASP.Net Core 1.0.1.

Open Visual Studio 2015. Tools ->Extensions and Update

You will see “Microsoft ASP.NET and Web Tools”, click on Update.

what is .net core

You will see Microsoft .NET Core 1.0.1 installer.

.net core

Install this tool.
Once installation was done, Open VS 2015
Go and create a new project, and you will see .NET Core in the template.


See below screen for more details.You can notice the message in right side saying –
“Project templates for creating ASP.NET Core applications for Windows, Linux and OS X using .NET Core.”

.net core

Create a Web Application, and you will see below welcome page.

introduction to .net core

ASP.Net Core Project layout

.net core 1.0

.Net Core with Visual Studio 2017

If you are using Visual Studio 2017 then you do not need an update, you can start development with .Net Core in Visual Studio 2017.

You can download Community Edition which is free to use for the individual.

Create a new project in Visual Studio 2017 and select ASP.Net Core Web Application.



Select your desired Project Template.



Once you create the project, solution explorer look like this. It is quite similar to what we have seen in Visual Studio 2015.

Application Settings (appsettings.json)

appsettings.json file contains all application's settings.  It holds different configuration settings for the different environment like development, staging, UAT, production.

Above screen shot was taken from local PC that's the reason it is showing appsettings.Developmen.json

Startup.cs

This file contains 2 important methods.

ConfigureServices() and Configure()

ConfigureServices() - This method gets called by the runtime. Use this method to add services to the container.


public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
        }


Configure() - This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
            }

            app.UseStaticFiles();

            app.UseMvc();
        }

So you can start the development with .Net Core in Visual Studio 2017 and Visual Studio 2015 as well.

A lot of stuff on .Net Core will be coming on my blog. Keep your eyes on SharePointCafe.Net

Why .Net Core?

Industry is moving towards Cloud and cloud based development is in demand.
Cross Platform compatibility

Summary:

1. .Net Core is a framework to build web applications.
2. .Net Core is cross-platform
3. .Net Core is easy to implement Microservice Architecture
4. Use of Docker containers is easy.
5. Till the publishing of this blog .Net Core 2.0 is the latest version
6. .Net Core is not the replacement of .Net


Next Blog - Introduction to .Net Core 2.0

Enjoy development using .NET Core.

Comments

Popular