Category Archives: ASP.NET Core

ASP.NET Core: My First New Project

In this tutorial section, we will discuss how to create a new project in Visual Studio using ASP.NET CORE. Once you have installed the Visual Studio 2015 tooling, you can start building a new ASP.NET Core Application .

STEP: 1

Once you have installed the Visual Studio 2015 tooling, you can start building a new ASP.NET Core Application using File → New Project menu option.

STEP: 2

On the New Project dialog box, you can able to see the three different templates for Web projects as shown below. After selecting ASP.NET Core Web Application (.NET Core),specify the location and name for your ASP.NET Core project click OK

ASP.NET Web Application − The simple ASP.NET application templates .

ASP.NET Core Web Application (.NET Core) − This will start you with a crossplatform compatible project that runs on the .NET Core framework.

ASP.NET Core Web Application (.NET Framework) − This starts a new project that runs on the standard .NET Framework on Windows.

STEP: 3

In the below dialog box, you can select a specific template for the ASP.NET application from the available ASP.NET Core Templates. Here, we select and start with an empty template. This would help us build it from scratch. Let us select the Empty template, turn off the Host in the cloud and click OK.

Now the Visual Studio will launch your new project. In the Solution Explorer window, you will see all the files that are in this project.

STEP: 4

Now you can run your application by pressing Ctrl+F5 or by going to the Debug menu. After going to the Debug menu, select Start Without Debugging.

STEP: 5

We can see it display only Hello World! This runs on http://localhost:44432. In your window system tray, you can also see that IIS Express is running as shown below.

What do you think?

I hope you have idea about creating first ASP.NET CORE application. I would like to have feedback from my posts readers. Your valuable feedback, question, or comments about this article are always welcome.

ASP.NET Core – Project Structure

If we had created a new blank project (EMPTY template) of ASP.NET Core in VS 2015, we see the following structure at the start. Here you can see a couple of things like wwwroot, Dependencies, Startup class and project.json and also you  see some other things like “References” and “Properties” these are the common parts of the .NET application.

 

 global.json

The file allows selection of the .NET Core tools version being used through the sdk property. The version (and optionally run time and architecture) are important because your computer have multiple versions of dnx.exe (.NET Execution Environment). 

 

wwwroot

ASP.NET Core has a new Feature for maintaining wwwroot folder where we put our static contents and libraries so that they are accessible right from the root of the project like HTML files, CSS , image files, and JavaScript files which are sent to the users’ browsers should be stored inside the wwwroot folder.

 Dependencies

There is a special folder called Dependencies which does not present physically but categorically shows the project dependency packages added in the project. Dependencies section is used to manage Bower and NPM tooling packages dependencies in your project. For example, Bower for client-side packages with their dependencies (i.e. jQuery, Bootstrap, Angular). Bower has bower.json file which contains all the packages and dependencies that have installed. So Bower and NPM dependencies appear here in this section. 

 Program.cs class

Program.cs file is the main entry point of our application. As per below code (inside the program.cs), you can see that this class contains a Main() method which looks quite familiar with that you have been seeing in C# Console Apps. This class is used to initiate, build, run the server (IIS and Kestrel) and host the  application. 

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;

namespace FirstASPCoreApplication
{
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();

host.Run();
}
}
}

 project.json

The first file of our project is project.json. All top level dependencies and libraries that are used by the application are listed in project.json. The project.json file maintains a list of packages used in a project, known as a package reference format.

 Startup.cs Class

The startup class is helpful to define the request handling pipeline and configure the Services required by the app. It has 2 methods ConfigureServices() and Configure(). This class basically is used to configure middle-wares on the request pipeline. The Startup class(Startup.cs) is where application pipeline is configured for request processing.

Web.config

In the previous versions, everything is handled by Web.Config but in ASP.NET Core, we don’t know about Web configure file and the only purpose it gives the instruction to iis for what should be done and it receives the http request.

What do you think?

I hope you have overview about ASP .NET Core Layout/structure of the Application. I would like to have feedback from my posts readers. Your valuable feedback, question, or comments about this article are always welcome.

 

Introduction to ASP.NET Core

Introduction

ASP.NET Core is the new web framework from Microsoft. It is the framework you want to use for web development with .NET. ASP.NET Core is a cross-platform, high-performance, open-source framework for building modern, cloud-based, Internet-connected applications. If you have any experience with MVC or Web API over the last few years, you will notice some familiar features.

ASP.NET Core 1.0 is a 1.0 release that includes Web API and MVC but doesn’t have SignalR or Web Pages.
It doesn’t yet support VB or F#.

What is ASP.NET Core

ASP.NET Core is an open source and cloud-optimized web framework for developing modern web applications that can be developed and run on across the many platforms like Windows, Linux and the Mac. It includes the MVC framework, which now combines the features of MVC and Web API into a single web programming framework.

What is New in ASP.NET Core?

ASP.NET Core ships entirely as NuGet packages. This allows you to optimize your application to include only the necessary NuGet packages rather than having all in application.

  • Open-source and community-focused.
  • A lightweight, high-performance, and modular HTTP request pipeline.
  • Ability to build and run on Windows, macOS, and Linux.
  • Ability to host on IIS, Nginx, Apache, Docker, or self-host in your own process.
  • ASP.NET Core apps can run on .NET Core or on the full .NET Framework.

What do you think?

I hope you have basic introduction and overview about ASP .NET Core. I would like to have feedback from my posts readers. Your valuable feedback, question, or comments about this article are always welcome.