Create Node.js web application using Visual Studio:

Here, you will learn how to create Node.js web application using Visual Studio.

If you have not installed project templates for Node.js in Visual Studio the visit Setup Visual Studio section.

First of all, create a new project by clicking on New Project.. on the start page or FILE menu. It will open 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 pan. Select Blank Node.js Web Application in the centre pane, give a project name and location and click OK. This will create 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 1337 port and sends Hello World text as a response to any http request.

Press F5 to run the web project. It will open command prompt and browser as shown below.

Create Node.js web server using Visual Studio
Node.js Web Application

So now, you can send different reponses based on the requested URLs the same way as shown in the Node.js web server section.