I have an action that creates a new e-mail in the database. The code is as follows:
[ValidateModel] public HttpResponseMessage Post(string username, [FromBody] EmailDTO email) ... this.repository.Add(username, email)
But an API user can set the ID property and cause conflicts in the database. Is it possible to ignore the “Id” property when binding without creating a custom mediation or modifying the DTO constructor? Like Bind (Exclude = '...'), but in WebApi?
Are there ways to prevent mass assignment in controller actions?
source share