开发者

ASP.NET MVC, WCF Service, and validation?

开发者 https://www.devze.com 2023-02-01 03:58 出处:网络
My ASP.NET MVC controller constructors create an instance of a service class by supplying it with (among other things) a ModelStateWrapper (similar to this article).Since this object is handled throug

My ASP.NET MVC controller constructors create an instance of a service class by supplying it with (among other things) a ModelStateWrapper (similar to this article). Since this object is handled through a reference, any changes made to it in the service are reflected when the controller accesses that ModelStateWrapper object.

I need to convert that logical service layer into WCF services that will be hosted in IIS.

Assuming I want to continue performing validation in the service layer, which approach is better?

  1. Pass the ModelStateWrapper object by reference (possible according to MSDN) with each service operation
  2. Keep trac开发者_运维问答k of errors in the service and have the client explicitly retrieve a list of errors after any/all service operations are performed
  3. Any other suggestions or links to articles that would help me perform validation behind a WCF service?

It should be noted that these services will eventually be consumed by a variety of UIs (ASP.NET MVC, Winform, Console, maybe even third-party).


Since you already have everything in place and working, pass the ModelStateWrapper over the wire to WCF service. Let it fill it out and send back.

The other platforms can use this same wrapper to get the error information.

0

精彩评论

暂无评论...
验证码 换一张
取 消