Check if null
if (foo == null)
{
return NotFound();
}
Check if save successful
if (newFoo == null)
{
return Conflict();
}
try
{
// Do something
}
catch (Exception ex)
{
return InternalServerError(ex);
}
Use validation attributes in the model with DataAnnotations
using System.ComponentModel.DataAnnotations;
[Required]
[MinLength(5)]
[MaxLength(10, ErrorMessage = "Foo max length is 10 characters")]
public string Foo {get; set; }
IdentifyConfig.cs: used to configure validation requirements
Startup.Auth.cs: used to configure authorization type (facebook, twitter, https/http, etc.)
// In production mode set AllowInsecureHttp = false
AllowInsecureHttp = false
CORS is a pain in the butt