What is the HTTP status code when a resource is not found? How to handle it?
What is the HTTP status code when a resource is not found? How to handle it?
22328-Aug-2023
Updated on 29-Aug-2023
Home / DeveloperSection / Forums / What is the HTTP status code when a resource is not found? How to handle it?
What is the HTTP status code when a resource is not found? How to handle it?
Aryan Kumar
29-Aug-2023The HTTP status code when a resource is not found is 404 Not Found. This status code indicates that the server cannot find the requested resource. The resource may have been deleted, moved, or never existed in the first place.
To handle a 404 Not Found error, you can return a response with the following information:
The following code shows how to handle a 404 Not Found error in a .NET Core API:
C#
In this code, the
Get()
action method first tries to get the product data from the database. If the product data is not found, the method returns a 404 Not Found response.Here are some additional tips for handling 404 Not Found errors: