title: FileExtensions attribute of DataAnnotations not working in MVC
body: <p>I am trying to upload a file using HTML FileUpload control in MVC. I want to validate the file to accept only specific extensions. I have tried using FileExtensions attribute of DataAnnotations namespace, but its not working. See code below -</p>
  
  <pre><code>public class FileUploadModel
      {
          [Required, FileExtensions(Extensions = (".xlsx,.xls"), ErrorMessage = "Please select an Excel file.")]
          public HttpPostedFileBase File { get; set; }
      }
  </code></pre>
  
  <p>In the controller, I am writing the code as below -</p>
  
  <pre><code>[HttpPost]
          public ActionResult Index(FileUploadModel fileUploadModel)
          {
              if (ModelState.IsValid)
                  fileUploadModel.File.SaveAs(Path.Combine(Server.MapPath("~/UploadedFiles"), Path.GetFileName(fileUploadModel.File.FileName)));
  
              return View();
          }
  </code></pre>
  
  <p>In View, I have written below code -</p>
  
  <pre><code>@using (Html.BeginForm("Index", "FileParse", FormMethod.Post, new { enctype = "multipart/form-data"} ))
  {
      @Html.Label("Upload Student Excel:")
      &lt;input type="file" name="file" id="file"/&gt;
      &lt;input type="submit" value="Import"/&gt;
      @Html.ValidationMessageFor(m =&gt; m.File)
  }
  </code></pre>
  
  <p>When i run the application and give an invalid file extension, its not showing me the error message.
  I am aware of solution to write custom validation attribute, but I dont want to use custom attribute. Please point out where I am going wrong.</p>