Wednesday, April 15, 2020

Create Node.js Web Application in Visual Studio

Here, you will learn how to create a Node.js web application using Visual Studio.
If you have not installed the project templates for Node.js in Visual Studio, then visit the Setup Visual Studio section.
First of all, create a new project by clicking on New Project.. on the start page or FILE menu. This will open a New Project dialog box as shown below.
Select Node.js Template in Visual Studio
As shown in the above figure, from the New Project dialog box, expand Installed -> Templates -> JavaScript -> Node.js in the left pane. Select the Blank Node.js Web Application in the centre pane, enter a project name and a location and click OK. This will create a Node.js web application project as shown below.
Node.js web server project in Visual Studio
As you can see, it has created server.js, which creates a web server listening on the 1337 port and sends the "Hello World" text as a response to any http request.
Press F5 to run the web project. It will open the command prompt and the browser, as shown below.
Create Node.js web server using Visual Studio
Node.js Web Application
So now, you can send different responses based on the requested URLs the same way as shown in the Node.js web server section.

No comments:

Post a Comment

How to register multiple implementations of the same interface in Asp.Net Core?

 Problem: I have services that are derived from the same interface. public interface IService { } public class ServiceA : IService { ...