I've just had to do something similar for server side validation only ( e.g checking file contents) and have ended up completely usurping the @Html.ValidationSummary altogether with quite a nice little work around.
We have a BaseController class that extends Controller, and inside we override the OnActionExecuting method for several purposes.
We create a new list in ViewBag for our error messages and ensure before any action runs it is initialized. Then we can add our errors to be displayed to it, and display on screen.
For the purposes of this question it would look like this.
public class BaseController : Controller
{
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (ViewBag.ErrorsList == null)
{
ViewBag.ErrorsList = new List<string>();
}
}
}
Then in our _Layout.cshtml add the following above your @RenderBody()
@if(ViewBag.ErrorsList.Count > 0)
{
<div class="container margin-top-10 alert alert-danger">
<h3><i class="glyphicon glyphicon-warning-sign"></i></h3><br/>
@foreach (string error in @ViewBag.ErrorsList)
{
@error <br/>
}
</div>
@RenderBody()
}
Now whenever an error occurs server side that we want to display as a validation error message we simply add it to our ViewBag.ErrorsList
ViewBag.ErrorsList.Add("Something bad happened...");
And voila, one custom container for your server side validation error messages with any styles you want on it, with errors passed in the same manner as ValidationSummary.