ASP.NET Core 2.0 MVC [Remote] Validation


How to implement model validation using [Remote] attribute in ASP.NET Core MVC.


In Startup configure middleware and services for MVC:

Add a model:

Add a controller:

Add a razor page and scripts for jQuery and its validation:


ASP.NET Core MVC gives a useful [Remote] attribute to make AJAX calls to controller/action to perform server-side validation, without the full post-back. The attribute uses jQuery and it’s validation JavaScript files to perform the AJAX requests.

We simply annotate the model property with [Remote] attribute, specifying Controller and Action. The action itself returns a JSON result with either validation message or true.

Source Code


Leave a Reply