.NET Fiddle

CSharp · Mvc

Model

using System;
using System.ComponentModel.DataAnnotations;

namespace HelloWorldMvcApp
{

}

View

@{
	Layout = null;
}

<!DOCTYPE html>
<!-- template from http://getbootstrap.com/getting-started -->

<html lang="en">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>Test</title>
		</style>
	</head>
	
	<body>
		<div>
			@Html.ValidationSummary()
		</div>
	</body>
</html>

Controller

using System;
using System.Web.Mvc;
using System.Collections.Generic;

namespace HelloWorldMvcApp
{
	public class HomeController : Controller
	{
		[HttpGet]
		public ActionResult Index()
		{
			ModelState.AddModelError("e", "Sample Error");
			return View();
		}


	}
}
;