I have the same problem.
I believe that the Microsoft.NET Framework 4.5 Language Pack is not installed on Azure Websites. Using a "cloud cloud project" seems to be an option since you can configure IIS directly.
Another solution is to wait for Microsoft to turn on language pack support in Azure ...
Personnaly, I decided to redefine the basic attributes. Most cheaters are [Required] and [Regular]. See below (Loc is my own localization function as I use gettext)
using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Globalization; using System.Web.Mvc; namespace Ic.DataAnnotations { public class RequiredLoc : RequiredAttribute, IClientValidatable { public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context) { yield return new ModelClientValidationRule { ErrorMessage = FormatErrorMessage(metadata.DisplayName), ValidationType = "required" }; } public override string FormatErrorMessage(string message) { base.FormatErrorMessage(message); return Localizer.Loc("Le champs '%1' est requis.", message); } } }
For regular expressions:
using System.ComponentModel.DataAnnotations; using System.Globalization; namespace Ic.DataAnnotations { public class RegularExpressionLoc : RegularExpressionAttribute { private readonly string _errorMessage; public RegularExpressionLoc(string errorMessage, string pattern) : base(pattern) { _errorMessage = errorMessage; } public override string FormatErrorMessage(string input) { return Localizer.Loc(_errorMessage); } } }
AND
using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Web.Mvc; namespace Ic.DataAnnotations { public class RegularExpressionValidator : DataAnnotationsModelValidator<RegularExpressionAttribute> { private readonly string _message; private readonly string _pattern; public RegularExpressionValidator(ModelMetadata metadata, ControllerContext context, RegularExpressionAttribute attribute) : base(metadata, context, attribute) { _pattern = attribute.Pattern; _message = attribute.FormatErrorMessage(""); } public override IEnumerable<ModelClientValidationRule> GetClientValidationRules() { var rule = new ModelClientValidationRule { ErrorMessage = _message, ValidationType = "regex" }; rule.ValidationParameters.Add("pattern", _pattern); return new[] { rule }; } } }
And at Global.asax
DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RegularExpressionLoc), typeof(RegularExpressionValidator));
source share