开发者

Validation of web service type

I have an asp.net mvc application that uses web service. I have various controllers that use the model provided by the web s开发者_C百科ervice. The problem is that client and server-side validation cannot be used as the class is not defined in my web application. How should I go about adding validation to this class?

Eg:

SomeController {
    someMethod(Service.User u) {
       if (ModelState.isValid) { // always valid as no annotations


Create a View Model and use that:

public class UserViewModel()
{
    public int UserId {get;set;}
    //more properties
}

Then map it back to the Service.User in the controller:

public ActionResult SomeMethod(UserViewModel viewModel)
{

}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜