Remote Validation On net core 5 web aspi not work

Viewed 31

I write remote validation on Model layer in my application.

[Remote("IsCompanyValid","Validation")]
[DisplayName("شناسه شرکت حمل و نقل")]
[Required(ErrorMessage = "{0} الزامی می باشد.")]
[Range(1, maximum: MaxValue, ErrorMessage = "{0} می تواند بین {1} تا {2} باشد.")]      
public decimal CompanyId { get; set; }

and create a validation controller in Api layer of application:

public class ValidationController: ControllerBase
    {
        [AllowAnonymous]
        public JsonResult IsCompanyValid(decimal companyId)
        {
            return new JsonResult(false);
        }
    }

not work only Remote attr on model!

ProjectImage

I add Method on Remote method type to POST and add [HttpPost] on controller! so not work any changed!

0 Answers
Related