c# - When to return ConflictResult in a Web Api Project -
in asp.net web api projects , 1 of http result datatypes returned in controller conflictresult. when return type of result in response?
i not find proper example , explanation on status , hope response contain sample code , explanation of reason why existing status such badrequestresult,exceptionresult,internalserverresult not applicable conflictresult?
you use response in scenarios same record updated simultaneously 2 users. e.g. edit conflict or if there version conflict between existing data , update request.
it return http status code 409
each 1 of requestresult mentioned have different meaning , allows client handle response differently. listing of http status codes provided in link.
the ones specified detailed below
badrequestresult
equivalent http status 400. badrequest indicates request not understood server. badrequest sent when no other error applicable, or if exact error unknown or not have own error code.
conflictresult
equivalent http status 409. conflict indicates request not carried out because of conflict on server.
internalserverresult
equivalent http status 500. internalservererror indicates generic error has occurred on server.
the reason implement conflictresult against internalserverresult or other have implementation adhere standards as possible , return specific result. same reason why return ioexception , not exception.
Comments
Post a Comment