输入无效的ID后应返回什么HTTP状态代码?

yoo*_*er8 1 http http-error http-headers asp.net-mvc-2

请求删除不存在的对象时应返回什么状态码?

public ContentResult DeleteEntity(int id, FormCollection FormData)
{
    Database db = new Database();
    TargetEntity te = db.TargetEntities.SingleOrDefault(t => t.Id == id);
    if(te == null)
    {
        Reponse.StatusCode = 400; //Is this correct?
        return Content("Deletion failed. Invalid ID: " + id);
    }
    //Delete the entity
    return Content("Successfully Deleted");
}
Run Code Online (Sandbox Code Playgroud)

该请求本身很好,只是发生了指定的ID无效(或该项目已被删除)的情况,因此我不确定400的范围。我敢肯定,这500个代码甚至不适合此代码,因为服务器上没有出错(只是要求删除不存在的内容)。

哪种状态码在这里最合适?

Dar*_*rov 5

请求删除不存在的对象时应返回什么状态码?

404 - Not Found