private string ValidateResume(HttpPostedFileBase file, ICollection<string> allowedFileExtensions, int maxContentLength) { var errorMessage = String.Empty; if (!file.HasFile()) { errorMessage = String.Format("File is not specified"); return errorMessage; } if (file.ContentLength > maxContentLength) { errorMessage = String.Format("File is too large, maximum allowed is: {0} MB", (maxContentLength / 1024 / 1024)); return errorMessage; } if (allowedFileExtensions != null && !allowedFileExtensions.Contains(file.FileName.Substring(file.FileName.LastIndexOf('.')))) { errorMessage = String.Format("Please upload file of type: {0}", String.Join(", ", allowedFileExtensions)); return errorMessage; } return errorMessage; }