MVC File upload unobtrusive validation

The solution contains MVC server side validators that validates a HttpPostedFileBase minimum file size(MinimumFileSizeValidator), maximum file size(MaximumFileSizeValidator) and the file extension respectively(ValidFileTypeValidator).

C# (8.1 MB)
 
 
 
 
 
5 Star
(2)
816 times
Add to favorites
9/12/2016
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

C#
using System;
using System.Web;
using technet.MVC.Validators;

namespace technet.MVC.Models
{
    public class ProfileModel
    {
        public string Username { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }

        [MinimumFileSizeValidator(0.5)]
        [MaximumFileSizeValidator(2.4)]
        [ValidFileTypeValidator("png")]
        //[FileUploadValidator(0.5, 2.4, "png")]
        public HttpPostedFileBase Avatar { get; set; }
    }
}