I have this method
[HttpPost]
public ContactModel Contact()
{
// validation contact must have at least first name
if (contactModel.firstName == null)
return null; // This works fine
/*
if (contactModel.firstName == null)
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Please provide first name"); // it gives error
// insert to database
}
So, how do I indicate to user to provide at least first name. I thought of adding some header to response, but that is not user friendly.
I also added
if (contactModel.firstName == null)
{
Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Please provide first name"); // this doesn't do any good either.
return null; // This works fine
}