From the course: Building Angular and ASP.NET Web API Apps

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Creating a Web API HttpDelete endpoint

Creating a Web API HttpDelete endpoint

From the course: Building Angular and ASP.NET Web API Apps

Start my 1-month free trial

Creating a Web API HttpDelete endpoint

- [Instructor] During this chapter we are going to learn how to delete an entry from the database, step by step and we will start by first creating an additional security step. And with security step, I mean a confirmation step. So when we are in the table of all the entries and we click the delete button we want to get a confirmation window where the user can either choose to confirm this request or to cancel it. So let us first create our API end point. In your entries controller, let us add a new HTTP verb and since we are going to send a deleted request let us start by first defining the HTTP verb. So for that we will write in here HTTP delete. Then next we write public IHTTP action result. And then the name is going to be delete entry. As a parameter it will simply have only the idea of the entry that we want to delete. So we write in here, int id. Next let us create a try and catch block by writing try and then double tab. Inside the try block we are going to write all the code.…

Contents