Providing localized error messages for non-attributed model validation in ASP.Net MVC 2?

后端 未结 3 1772
夕颜
夕颜 2020-12-05 03:13

I\'m using the DataAnnotations attributes along with ASP.Net MVC 2 to provide model validation for my ViewModels:

public class ExamplePersonViewModel {
    [         


        
3条回答
  •  盖世英雄少女心
    2020-12-05 03:32

    List of messages (MVC 3.0):

    ActionMethodSelector_AmbiguousMatch
    ActionMethodSelector_AmbiguousMatchType
    AsyncActionMethodSelector_AmbiguousMethodMatch
    AsyncActionMethodSelector_CouldNotFindMethod
    AsyncCommon_AsyncResultAlreadyConsumed
    AsyncCommon_ControllerMustImplementIAsyncManagerContainer
    AsyncCommon_InvalidAsyncResult
    AsyncCommon_InvalidTimeout
    AuthorizeAttribute_CannotUseWithinChildActionCache
    ChildActionOnlyAttribute_MustBeInChildRequest
    ClientDataTypeModelValidatorProvider_FieldMustBeNumeric
    Common_NoRouteMatched
    Common_NullOrEmpty
    Common_PartialViewNotFound
    Common_PropertyCannotBeNullOrEmpty
    Common_PropertyNotFound
    Common_TriState_False
    Common_TriState_NotSet
    Common_TriState_True
    Common_TypeMustDriveFromType
    Common_ValueNotValidForProperty
    Common_ViewNotFound
    CompareAttribute_MustMatch
    CompareAttribute_UnknownProperty
    Controller_UnknownAction
    Controller_UpdateModel_UpdateUnsuccessful
    Controller_Validate_ValidationFailed
    ControllerBase_CannotExecuteWithNullHttpContext
    ControllerBase_CannotHandleMultipleRequests
    ControllerBuilder_ErrorCreatingControllerFactory
    ControllerBuilder_FactoryReturnedNull
    ControllerBuilder_MissingIControllerFactory
    CshtmlView_ViewCouldNotBeCreated
    CshtmlView_WrongViewBase
    DataAnnotationsModelMetadataProvider_UnknownProperty
    DataAnnotationsModelMetadataProvider_UnreadableProperty
    DataAnnotationsModelValidatorProvider_ConstructorRequirements
    DataAnnotationsModelValidatorProvider_ValidatableConstructorRequirements
    DefaultControllerFactory_ControllerNameAmbiguous_WithoutRouteUrl
    DefaultControllerFactory_ControllerNameAmbiguous_WithRouteUrl
    DefaultControllerFactory_ErrorCreatingController
    DefaultControllerFactory_NoControllerFound
    DefaultControllerFactory_TypeDoesNotSubclassControllerBase
    DefaultModelBinder_ValueInvalid
    DefaultModelBinder_ValueRequired
    DefaultViewLocationCache_NegativeTimeSpan
    DependencyResolver_DoesNotImplementICommonServiceLocator
    ExceptionViewAttribute_NonExceptionType
    ExpressionHelper_InvalidIndexerExpression
    FilterAttribute_OrderOutOfRange
    HtmlHelper_InvalidHttpMethod
    HtmlHelper_InvalidHttpVerb
    HtmlHelper_MissingSelectData
    HtmlHelper_TextAreaParameterOutOfRange
    HtmlHelper_ValidationParameterCannotBeEmpty
    HtmlHelper_ValidationParameterMustBeLegal
    HtmlHelper_ValidationTypeCannotBeEmpty
    HtmlHelper_ValidationTypeMustBeLegal
    HtmlHelper_ValidationTypeMustBeUnique
    HtmlHelper_WrongSelectDataType
    JsonRequest_NotAllowed
    ModelBinderAttribute_ErrorCreatingModelBinder
    ModelBinderAttribute_TypeNotIModelBinder
    ModelBinderDictionary_MultipleAttributes
    ModelMetadata_PropertyNotSettable
    MvcRazorCodeParser_CannotHaveModelAndInheritsKeyword
    MvcRazorCodeParser_ModelKeywordMustBeFollowedByTypeName
    MvcRazorCodeParser_OnlyOneModelStatementIsAllowed
    OutputCacheAttribute_CannotNestChildCache
    OutputCacheAttribute_ChildAction_UnsupportedSetting
    OutputCacheAttribute_InvalidDuration
    OutputCacheAttribute_InvalidVaryByParam
    PrivateAssociatedMetadataTypeTypeDescriptor_MetadataTypeContainsUnknownProperties
    RedirectAction_CannotRedirectInChildAction
    ReflectedActionDescriptor_CannotCallInstanceMethodOnNonControllerType
    ReflectedActionDescriptor_CannotCallMethodsWithOutOrRefParameters
    ReflectedActionDescriptor_CannotCallOpenGenericMethods
    ReflectedActionDescriptor_CannotCallStaticMethod
    ReflectedActionDescriptor_ParameterCannotBeNull
    ReflectedActionDescriptor_ParameterNotInDictionary
    ReflectedActionDescriptor_ParameterValueHasWrongType
    ReflectedAsyncActionDescriptor_CannotExecuteSynchronously
    ReflectedParameterBindingInfo_MultipleConverterAttributes
    RemoteAttribute_NoUrlFound
    RemoteAttribute_RemoteValidationFailed
    RequireHttpsAttribute_MustUseSsl
    SessionStateTempDataProvider_SessionStateDisabled
    SingleServiceResolver_CannotRegisterTwoInstances
    SynchronizationContextUtil_ExceptionThrown
    TemplateHelpers_NoTemplate
    TemplateHelpers_TemplateLimitations
    Templates_TypeMustImplementIEnumerable
    TypeCache_DoNotModify
    ValidatableObjectAdapter_IncompatibleType
    ValueProviderResult_ConversionThrew
    ValueProviderResult_NoConverterExists
    ViewDataDictionary_ModelCannotBeNull
    ViewDataDictionary_WrongTModelType
    ViewMasterPage_RequiresViewPage
    ViewPageHttpHandlerWrapper_ExceptionOccurred
    ViewStartPage_RequiresMvcRazorView
    ViewUserControl_RequiresViewDataProvider
    ViewUserControl_RequiresViewPage
    WebFormViewEngine_UserControlCannotHaveMaster
    WebFormViewEngine_ViewCouldNotBeCreated
    WebFormViewEngine_WrongViewBase
    

提交回复
热议问题