Use FileTypeChecker in ASP.NET Core web applications
masterFor ASP.NET Core, use the companion package FileTypeChecker.Web to add validation attributes to your IFormFile models. This allows for automatic validation during model binding.
public class UploadModel
{
[AllowedFileTypes(FileType.Jpeg, FileType.Png)]
[MaxFileSize(5 * 1024 * 1024)] // 5MB
public IFormFile ProfileImage { get; set; }
}