Using Remote validation with ASPNET Core
March 24, 2016 by Anuraj
ASP.NET MVC ASP.NET Core ASP.NET5 Remote Validation
Remote validation allows the developer to call the controller actions using client side script. This is extremely useful when you want to perform a back end query without having to perform a full server postback. ASP.NET MVC Remote configuraion helps us to do this by decorating the model properties with remote attribute. This post is about implementing remote validation in ASP.NET Core. For remote validation first you need to decorate the model class property with remote attribute.
The ValidateEmailAddress is an action method in Home controller, which returns true if the email address not exists in the database and if exists it returns a string which will displayed in the view. Here is the controller method.
_repository is a repository implementation, which will be injected in the controller constructor. And here is the view.
You need to add few script references to make remote attribute work properly.
Here is the screenshot of the application
Happy Programming
Copyright © 2024 Anuraj. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Powered by Jekyll. Hosted with ❤ by GitHub