How can I approach client-side validation using MVC and WCF without duplicating the logic?

I can search for the nonexistent Holy Grail here, but it's worth it. To get started, here is a brief overview of our architecture:

  • Data access : repository classes that communicate with SQL Server through the Entity Framework
  • Business logic . Manager classes invoke the data layer and display data in the domain model.
  • Domain Models : POCOs That Represent Our Domain
  • Service library / Service facade : issues CRUD operations for POCOs
  • Presentation : ASP.NET MVC (v2, but if necessary, can be ported to v3 - we are still early in our project)

The problem we are trying to solve is how to automatically create a client-side check to handle basic problems, such as required fields, minimum and maximum lengths, numerical ranges, etc. - just your basic first line of defense of a thing.

If we used DataAnnotations in the POCOs of the domain model (which sounds attractive at the beginning), we could let jQuery an unobtrusive check do the work for us. To make it work, we will need to reference the Domain Model library both at the service level and at the presentation level, because DataAnnotations are not transmitted through WCF. Unfortunately, we need to reuse the WCF service in several applications, and if we go on this route, we are likely to create problems with locking the version.

, , , , .

( , ), WCF .

, , . , . , , .

, ?

EDIT:

. , , , DataAnnotations: , , Serializable WCF.

+3
3

WCF , . - , :

  • WCF, , .

  • .

killer, WCF , , .: (

+2
+1

All Articles