System.Web.Mvc missing reference to ModelClientValidationRule

I am trying to write some client validation in a class library. I added a link 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

Could not find the type or namespace ModelClientValidationRule (are you missing a using directive or an assembly reference?)

I have targeted .Net Framework 4 and this MSDN link indicates it should be correct, so I'm a bit puzzled as to why the error is happening.

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


source to share

2 answers

As long as the ModelClientValidationRule is in the System.Web.Mvc namespace, it is in the System.Web.WebPages assembly, so you need to reference that assembly as well.



In addition to Nils answers, you might need to add the Microsoft.ASP.NET.MVC package from NuGet.



All Articles