mardi 11 août 2015

MVC form send value to remote verifier

I'm trying to use a remote verifier for user email existence against my database, my problem is it's posting my email under a name i don't know how to get on the Action as a parameter.

This is my attribute:

[Remote( "EmailExists", "Register", HttpMethod = "POST", ErrorMessage = "Email already exists!" )]
public string Email { get; set; }

This is my Action:

public JsonResult EmailExists( string email )
    using (var db = new SOSEntities())
        var user = db.VT_Usuario.FirstOrDefault( us => email ) );

        return Json( user == null );

and this is how the email is being posted to the action, i got this info on the headers of the post (Form Data):


My user class is inside a ViewModel with some other models that i use on the project, the user data is inside a user object inside the ViewModel, and by that the data is posted as user.Email.

What can i do to work around this ?

Aucun commentaire:

Enregistrer un commentaire