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)
845 times
Add to favorites
9/12/2016
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using technet.MVC.Models;

namespace technet.MVC.Controllers
{
    public class ProfileController : Controller
    {
        [HttpGet]
        public ActionResult Index()
        {
            return View(new ProfileModel());
        }

        [HttpPost]
        public ActionResult Index(
            ProfileModel model)
        { 
            if(!ModelState.IsValid)
            {
                return View(model);
            }

            return View(model);
        }
    }
}