System.Web.Mvc.ModelState does not contain a defin

2019-07-06 16:10发布

问题:

I am trying to move my login method from a controller action into a service class. On compilation I'm being told that System.Web.Mvc.ModelState does not contain a definition for 'IsValid' Am I missing a using statement?

回答1:

ModelState is both the name of a property on the Controller baseclass and the name of a class.

The code you moved was using the property, the error comes from trying to use the class instead.