Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Web.Mvc missing reference to ModelClientValidationRule

I am trying to write some client validation in a class library. I added a reference to System.Web.Mvc on my local machine here C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies\System.Web.Mvc.dll but I am getting the error

The type or namespace ModelClientValidationRule could not be found (are you missing a using directive or an assembly reference?)

I am targeting .Net Framework 4 and this MSDN link indicates that should be correct, so I am little stumped as the why the error is occurring.

I am using VS2013 and have .Net 4.5 on my local machine, and have written client validation in other projects. I expect that I could resolve this issue by adding the MVC NuGet package, but I would like to explore the alternatives.

like image 884
ste-fu Avatar asked Jan 08 '23 12:01

ste-fu


1 Answers

While ModelClientValidationRule is in the namespace System.Web.Mvc, it is in the assembly System.Web.WebPages, so you need to reference that assembly too.

like image 115
Nils O Avatar answered Jan 11 '23 23:01

Nils O