(C# ASP.NET Core) Connecting HttpRepl to a Web Api Endpoint

Before we can execute and test any web api, we have to establish a connection between httprepl and our web server. If you are following this chapter, then you must have observed that each of our route templates starts with the segment "doctor". Technically, it is called an end-point. The objective of this tutorial is to learn how to connect to a server, and how to get a list of available endpoints, and how to finally navigate to a specific endpoint - which is "doctor" in our case. In the coming tutorials we shall make calls to the various types of web api that we have already added to our web api project.

Categories | About |     |  

Parveen,

Connecting to your Web Server

The first thing that we have to do is to establish a connection with our server. So open your project and run the application, and allow the home page to open. Take note of the IP address of your server.

Next use the menu Tools > Command Line > Developer Command Prompt to open the console. Type the command httprepl followed by the complete address of your server - as you are seeing here.


httprepl https://localhost:7264/

Hit the enter key, and if everything goes right, you should be able to see your IP Address as a path as you are seeing here. This path is very similar to what you see on a DOS command prompt.


https://localhost:7264/>

Infact various DOS commands can be run here too. For example we can use the ls or dir command to view the various available endpoints.

So, now type ls on the command prompt as you are seeing here - and hit the enter key. The command completes almost immediately, and we can see two endpoints listed - the first one is the root, and the second one is the doctor - this is the same endpoint that we have used in writing our web api.


https://localhost:7264/> ls

.        []
doctor   [POST]

https://localhost:7264/>

If you want I can open our web api project and show this to you. Come to the solution explorer and locate the program.cs file. Double click and open it, and scroll to the part that you are seeing here. You can see that all the route templates of our web api start with doctor - and this is the same endpoint that has been listed by http repl(see the linked video).

Come back to the http repl console. Now it is time to navigate to the doctor endpoint. Basically we have to "change" the directory to doctor. The command for this is cd, which is, again, of the same name as the familiar DOS command called cd.

So type cd followed by doctor and hit the enter key.


https://localhost:7264/> cd doctor

We observe that now our command prompt shows a connection to the doctor directory.


https://localhost:7264/doctor>

It is possible to jump "upwards" in the directory tree by using the familiar cd dot dot command. For this type cd ..


https://localhost:7264/doctor> cd ..

And you can see, we are back to the root.


https://localhost:7264/>

Now we are ready to test our web api - and we shall be doing that in the next tutorials - Thankyou!

Video Explanation (see it happen!)

Please watch the following youtube video:


This Blog Post/Article "(C# ASP.NET Core) Connecting HttpRepl to a Web Api Endpoint" by Parveen is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.