Lecture thumbnail 0:00 / 0:00 Select ASP.NET Core empty.
Click Next.
And here enter the project name as
Minimal API
OK, that’s enough.
Location is
C drive ASPNET Core
Solution name is Minimal API Solution
OK, the project name can be anything.
And Create.
OK, we have regular code for Program.cs file.
And it has default code for MapGet.
So as you can guess, it receives the request at the specified route.
And provides this returned value as response.
Alternatively, as we have already learned in the routing section,
we can receive the HTTP context object as parameter
and can write something in this lambda expression.
For example, response.writeAsync
Hey context, you have a response object, right?
Write something, for example,
Hello world from get.
OK, this receives the get request at the specified route.
And this will receive the post request.
That is MapPost
Similarly, you can also try using put as well as delete requests.
Generally, we make put request for updation of the data in the database table.
And we make delete request for deleting a particular record in the table.
OK, let’s run this application and test it with Postman.
OK, as you can see, the URL is localhost 5075.
Let’s make a request to the same by using Postman.
Make sure you have installed Postman.
Of course, we already did it in the beginning of the course itself.
So enter the URL as localhost 5075.
And we are going to make get request.
And we are getting the appropriate response.
getHelloWorld
In the same way, of course, the post request work.
OK, we have already did this kind of applications in the very beginning of the course itself in the routing section.
The point here is,
we are creating such applications with minimal API.
That is MapGet and MapPost, any Map* methods.