0

Here im using Vs2013 updated 4 when i'm try Microsoft.Web.Mvc i'm Getting error at .Mvc

public class FileUpload
    {
  [Required, Microsoft.Web.Mvc.FileExtensions(Extensions = "csv", 
             ErrorMessage = "Specify a CSV file. (Comma-separated values)")]
        public HttpPostedFileBase File { get; set; }

I got this from Html helper for <input type="file" />

Md Ghousemohi
  • 197
  • 2
  • 13
  • What error are you getting? –  Feb 03 '18 at 07:56
  • @StephenMuecke i got Error at .Mvc Not found but i clear this by installing Mvc4Features – Md Ghousemohi Feb 03 '18 at 07:58
  • And that attribute was just a trial (which is why it was in the MvcFutures) - Its was never implemented in MVC and is not supported –  Feb 03 '18 at 07:59
  • then y im getting an error even wen im using mvc5 – Md Ghousemohi Feb 03 '18 at 08:00
  • If you want to validate a file extension (both client and server side), refer [this answer](https://stackoverflow.com/questions/40199870/how-to-validate-file-type-of-httppostedfilebase-attribute-in-asp-net-mvc-4/40200034#40200034) –  Feb 03 '18 at 08:00
  • I really thanks a lot bt why this https://stackoverflow.com/questions/304617/html-helper-for-input-type-file came into Picture – Md Ghousemohi Feb 03 '18 at 08:02
  • Its not in MVC-5 (in fact its not in any version of MVC. The futures project was just for testing various things to consider if they should be included in future releases (and that one was not) –  Feb 03 '18 at 08:03
  • Refer also [this answer](https://stackoverflow.com/questions/35329402/system-web-mvc-vs-microsoft-web-mvc/35330351#35330351) –  Feb 03 '18 at 08:04
  • @StephenMuecke tq soo much – Md Ghousemohi Feb 03 '18 at 08:08

1 Answers1

0

There are a lot of solutions out there to implement a FileExtensions attribute that will work on HttpPostedFileBase object. But since it is implemented in MVC Futures just go to nuget and add the appropriate Futures package to your project. For MVC 5 use Microsoft.AspNet.Mvc.Futures. In your code, reference Microsoft.Web.Mvc.FileExtensions to specify the one in the Futures package rather than the one in the DataAnnotations package which only works on strings. I am curious why this most widely needed item was not made part of standard MVC5.