mvc4 Recaptcha与Json ActionView

时间:2013-08-03 03:16:41

标签: json asp.net-mvc-4

我最近搬到了MVC4,我很难在Controller中更改Recaptcha,以便它可以使用Json,例如这是有效的

 //This Works
 [HttpPost]
    public ActionResult create(Registration registration)
    {
        if (!ReCaptcha.Validate(privateKey: "key-value"))
        { return Content("Wrong Captcha please try again"); }


    }
 // This does not work it gives an error saying
[HttpPost]
    public JsonResult create(Registration registration)
    {

        if (!ReCaptcha.Validate(privateKey: "key-value"))
        { return Content("Wrong Captcha please try again"); }


    }

无法将类型'System.Web.Mvc.ContentResult'隐式转换为'System.Web.Mvc.JsonResult'
这是我在切换到Json时得到的错误有没有办法纠正它?

0 个答案:

没有答案