I am trying to create a remote validation as follows:
[Remote("CheckValue", "Validate", ErrorMessage="Value is not valid")]
public string Value { get; set; }
I am using ASP.NET Core (ASP.NET 5) and it seems Remote is not available. Does anyone know how to do this with ASP.NET CORE?
The RemoteAttribute is part of ASP.Net MVC Core:
Microsoft.AspNet.Mvc
namespace. See RemoteAttribute
in github.Microsoft.AspNetCore.Mvc
namespace. See RemoteAttribute
in github.For example, in RC1 create a new MVC site with authentication. Then update the generated LoginViewModel
with a dummy remote validation calling a method in the home controller:
using Microsoft.AspNet.Mvc;
using System.ComponentModel.DataAnnotations;
public class LoginViewModel
{
[Required]
[EmailAddress]
[Remote("Foo", "Home", ErrorMessage = "Remote validation is working")]
public string Email { get; set; }
...
}
If you create that dummy method in the home controller and set a breakpoint, you will see it is hit whenever you change the email in the login form:
public class HomeController : Controller
{
...
public bool Foo()
{
return false;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With