MVC中的远程验证不起作用

时间:2016-03-28 11:17:11

标签: asp.net-mvc validation

大家好我正在开发一个MVC网站和验证注册页面i,m使用远程验证电子邮件地址和用户名我有远程问题,s工作正常的用户名但电子邮件地址不起作用请救命 谢谢......`

[Remote("EmailAddressExist", "Validation", HttpMethod = "POST", ErrorMessage="not available")] 
public string EmailAddress { get; set; }
[Remote("UserNameExist", "Validation", HttpMethod = "POST", ErrorMessage = "not available")]
public string UserName { get; set; }

这是我的控制器。

    [AllowAnonymous]
    [OutputCache(Location = OutputCacheLocation.None, NoStore = true)]
    public JsonResult EmailAddressExist(string email)
    {
        return Json(!db.Members.Any(s => s.EmailAddress==email),JsonRequestBehavior.AllowGet);
    }
    [AllowAnonymous]
    [OutputCache(Location = OutputCacheLocation.None, NoStore = true)]
    public JsonResult UserNameExist(string username)
    {
        return Json(!db.Members.Any(s=>s.UserName==username),JsonRequestBehavior.AllowGet); 
    }

0 个答案:

没有答案