Dzień dobry.
W nowym projekcie, który całe szczęście zbliża się już do końca próbujemy zastosować atrybut walidacyjny [Remote]. Ze względu na pewną śmieszną architekturę aplikacji większość routów jest rozpisana osobno w RoureConfig.
Tak więc:
[kontroller] SpecificationController
[HttpGet] public JsonResult EmailExists(string email) { // jakas validacja maila, trim itd itp return Json(true, JsonRequestBehavior.AllowGet); // true tu dane tylko dla przykładu }
[RouteConfig]
routes.MapRoute(name: "EmailExists", url: "Specification/EmailExists", defaults: new {controller = "Specification", action = "EmailExists" });
A w ViewModelu mamy coś takiego:
[Required] [EmailAddress] [DataType(DataType.EmailAddress)] [Remote("EmailExists", "Specification", ErrorMessage = "Email exists!")] public string Email { get; set; }
Wszystko dobrze fajnie... debugger pokazuje, że akcja kontrolera jest osiągana, ale string e-mail jest pusty (null) - nie binduje się
Próbowaliśmy już desperacko różnych konfiguracji routeconfiga (niektóre bez sensu ale tonący... itd):
routes.MapRoute(name: "EmailExists", url: "Specification/EmailExists", defaults: new {controller = "Specification", action = "EmailExists", email = UrlParameter.Optional }); routes.MapRoute(name: "EmailExists", url: "Specification/EmailExists/{email}", defaults: new {controller = "Specification", action = "EmailExists", email = UrlParameter.Optional });
Czy ktoś ma jakiś pomysł o co chodzi?