In this article, We will explain how to Install a .NET Core tools preview for Visual Studio and how to print “Hello World” in the latest Asp.Net Core 1.0.
First download Visual Studio 2015 with Update 3 through the link click here.
Go to Install .NET Core tools preview for Visual Studio. This .NET Core tool adds support for .NET Core projects in Visual Studio 2015.
This is really interesting !! Open Visual Studio 2015 and create a new Project.
Open Templates – > Visual C# -> Click .NET Core Category and you can see “ASP.NET Core Web Application” template.
Select Empty Templates ( based on your requirement ) in Asp.Net Core Templates Category. If you are going to host the app in Microsoft Azure Service and check in the “Host in the cloud option”.
Open “Startup.cs” class in “HelloWorldDotnetCore” project folder.
We are creating a mini middle ware Application, using a lambda expression in “app.Run”. This piece of code is creating “Hello World”
C# Code
using
System;
System.Collections.Generic;
System.Linq;
System.Threading.Tasks;
Microsoft.AspNetCore.Builder;
Microsoft.AspNetCore.Hosting;
Microsoft.AspNetCore.Http;
Microsoft.Extensions.DependencyInjection;
Microsoft.Extensions.Logging;
namespace
HelloWorldDotnetCore
{
public
class
Startup
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
void
ConfigureServices(IServiceCollection services)
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
loggerFactory.AddConsole();
if
(env.IsDevelopment())
app.UseDeveloperExceptionPage();
app.Run(async (context) =>
await context.Response.WriteAsync(
" Hello World!"
);
});
Output 1
Two “app.run” doesn’t work in .Net Core followed by using “app.Use”. It will pass two parameters and Add the next middleware content in .Net Core.
C# Code:
app.Use(async (context, next) =>
"Hello World!!"
await next();
" Welcome to Dotnet Core "
Output 2
We learned how to Install .NET Core tools preview for Visual Studio and how to print “Hello World” in the latest ASP.NET Core 1.0.