I am currently working on a 4 tier application, Core, Data, Shared, UI currently how it stands all our models are located inside the Shared project which is a class Library in one of the models we have the following implementation:
[Remote("UsernameUnique", "Register")]
[Required]
public string Username { get; set; }
This currently points to a Json method which is located inside the Register controller which is a part of the UI project as shown here,
public JsonResult UsernameUnique(UserRegistrationPartOne model)
{
var t = model;
return Json(false, JsonRequestBehavior.AllowGet);
}
But when I run this project and navigate to the sign up part it throws the error No url for remote validation could be found. I have been looking at the following just confirm I hadn't missed anything:
According to what they do and what I've done is pretty much Identical, the only thing that I could think off which would be causing this problem is the fact the model is located in the Shared Project whilst its required on a view which is located in the UI Project? or maybe it could be something else?
Your method needs to be
public JsonResult UsernameUnique(string Username)
A RemoteAttribute
sends back the value of the property (not a model)
Side note: If you need to send back other properties of your model in order to do the validation, then you can use the AdditionalFields
property of RemoteAttribute
public JsonResult UsernameUnique(string userName)
{
/// Checking your validation
return Json(false, JsonRequestBehavior.AllowGet);
}
if you want add additional field you can add to Action like
public JsonResult UsernameUnique(string userName, FieldType additionalValue)
And Update the remote attribute like:
[Remote("UsernameUnique", "Register", AdditionalFields = "YourPropName"))]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.