A Quick Start With ASP.NET Core

What is .NET Core?

.NET Core is a general purpose development platform that supports various platforms, like Windows, MacOS, or Linux and can be used in a device, a cloud, or embedded/IoT scenarios.

Features of .NET Core

  • Flexible deployment
  • Cross-platform
  • Command-line tools
  • Compatible
  • Open source
  • Supported by Microsoft

How to Install ASP.NET Core on Windows

Download and install the below items:

If you don’t have Visual Studio 2015 installed, do install it from the link given below:
Visual Studio Community 2015 it’s for free.

When you install the "vs2015.3.exe”-(Update 3), its shows an error sometimes. In my case, it restarted the system but now it’s resolved.

Mentioned below are some advanced and specific downloads,

downloads

For more details, visit here.

Once finished the installation, you should be able to create .NET Core application from the command line.

Creating our Frist.Net Core Application using CLI (Command Line Interface)

In our first step, we need to verify the installation; for this, open the command prompt with admin privilege and type,

“dotnet --version”


command

We get the output with the version details of .Net. Let’s start creating a new application using some commands.

Run the following commands in the command prompt with admin privilege:

“mkdir MyFirstCoreApp”
“cd MyFirstCoreApp”
“dotnet new ” // To use create a new core app
“dotnet restore” // To restore all the dependencies
“dotnet run” // to compile and run the application

command

Yes! Our first application is completed. Now, we have to take a look in the directory “MyFirstCoreApp”. 

directory
Check the items created in our application.

In the next step, please delete all the files from the folder except Program.cs and project.json.

Open the command prompt with admin privilege and run the following commands:

“dotnet restore” // To restore all the dependencies
“dotnet run” // to compile and run the application

Yes ! It is working fine.

Actually, we need a .cs and .jason file only to start a project. The other files will be automatically created when we build an app.

You can create your own application, the same way.

Create our Frist ASP.Net Core Application using CLI (Command Line Interface)

Open your command prompt with admin privilege and run the following commands:

“dotnet new -t web “ // To Creates a new ASP.NET Core app
“dotnet restore” // To restore all the dependencies
“dotnet run” // to compile and run the application

Now, open your browser and type http://localhost:5000/

You can see that your ASP.NET application is running.

application

If you open the folder, you can see that the following items were created in the folder,

folder

Create our First ASP.Net Core Application using Visual Studio

Open the Visual Studio.

Go to File=>New=>Project

You can see a separate template for .net framework and .Net Core.

template

And, there is another tab for .NET Core.

Click on the ASP.NET Core Web Application.

Web Application

Select Web Application and Click “OK”.

Web Application

Now, a New project is created. See the solution explorer.

solution explorer

Now, run the application.

Application

Now, we can edit and do some changes. Add these changes in Home controller.

  1. public IActionResult Index() {  
  2.     ViewBag.Message = "This is my First ASP.NET Core Application";  
  3.     return View();  
  4. }  
Change the Index.chtml also, with the following code:

<h2> @ViewBag.Message</h2>

Now, we can run the application.

application  
Yes! Our application is running successfully.

Conclusion

In this article, we learned how to install and create .Net core applications with different methods.