Sitecore.NET 8.1中的reCAPTCHA V2(修订版151003)错误
问题描述:
我们在最初的开发中遇到了下面的错误。Sitecore.NET 8.1中的reCAPTCHA V2(修订版151003)错误
我们遇到了Google的错误:曾尝试保存表单。
We experienced a technical difficulty while processing your request.
Your data may not have been correctly saved.
欲了解更多详情,请查找附件。 当前出错
Message: The remote server returned an error: (403) Forbidden.
Source: System at System.Net.WebClient.DownloadDataInternal(Uri
address, WebRequest& request) at
System.Net.WebClient.DownloadString(Uri address) at
Sitecore.Forms.Mvc.Validators.RecaptchaResponseValidatorAttribute.ValidateFieldValue(IViewModel
model, Object value, ValidationContext validationContext) at
Sitecore.Forms.Mvc.Validators.DynamicValidationBase.IsValid(Object
value, ValidationContext validationContext) at
System.ComponentModel.DataAnnotations.ValidationAttribute.GetValidationResult(Object
value, ValidationContext validationContext) at
System.Web.Mvc.DataAnnotationsModelValidator.Validate(Object
container) at
System.Web.Mvc.ModelValidator.CompositeModelValidator.<Validate>d__1.MoveNext()
at System.Web.Mvc.DefaultModelBinder.OnModelUpdated(ControllerContext
controllerContext, ModelBindingContext bindingContext) at
System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext
controllerContext, ModelBindingContext bindingContext) at
Sitecore.Forms.Mvc.Controllers.ModelBinders.SectionModelBinder.BindFieldCollection(ControllerContext
controllerContext, ModelBindingContext bindingContext, IEnumerable`1
list) at
System.Web.Mvc.DefaultModelBinder.BindProperty(ControllerContext
controllerContext, ModelBindingContext bindingContext,
PropertyDescriptor propertyDescriptor) at
System.Web.Mvc.DefaultModelBinder.BindProperties(ControllerContext
controllerContext, ModelBindingContext bindingContext) at
System.Web.Mvc.DefaultModelBinder.BindComplexElementalModel(ControllerContext
controllerContext, ModelBindingContext bindingContext, Object model)
at
System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext
controllerContext, ModelBindingContext bindingContext) at
System.Web.Mvc.DefaultModelBinder.UpdateCollection(ControllerContext
controllerContext, ModelBindingContext bindingContext, Type
elementType) at
System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext
controllerContext, ModelBindingContext bindingContext) at
System.Web.Mvc.DefaultModelBinder.GetPropertyValue(ControllerContext
controllerContext, ModelBindingContext bindingContext,
PropertyDescriptor propertyDescriptor, IModelBinder propertyBinder)
at System.Web.Mvc.DefaultModelBinder.BindProperty(ControllerContext
controllerContext, ModelBindingContext bindingContext,
PropertyDescriptor propertyDescriptor) at
System.Web.Mvc.DefaultModelBinder.BindProperties(ControllerContext
controllerContext, ModelBindingContext bindingContext) at
System.Web.Mvc.DefaultModelBinder.BindComplexElementalModel(ControllerContext
controllerContext, ModelBindingContext bindingContext, Object model)
at
System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext
controllerContext, ModelBindingContext bindingContext) at
Sitecore.Forms.Mvc.Controllers.ModelBinders.FormModelBinder.BindModel(ControllerContext
controllerContext, ModelBindingContext bindingContext) at
System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext
controllerContext, ParameterDescriptor parameterDescriptor) at
System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext
controllerContext, ActionDescriptor actionDescriptor) at
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext
controllerContext, String actionName) 4908 08:35:10 WARN Web Forms
for Marketers: an exception 'The remote server returned an error:
(403) Forbidden.' has occured while trying to execute an action ''.
答
这是因为代理问题:
var response = Request["g-recaptcha-response"];
var client = new WebClient();
var url = string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", secretKey, response);
NetworkCredential netcredit = new NetworkCredential("username", "password", "domain");
client.Credentials = netcredit;
WebProxy proxyObject = new WebProxy("proxyurl");
proxyObject.Credentials = new System.Net.NetworkCredential("username", "password", "domain");
client.Proxy = proxyObject;
var result = client.DownloadString(url);
var obj = JObject.Parse(result);
status = (bool)obj.SelectToken("success");
你的问题还不清楚。你应该清楚地描述如何重现问题。 – svgrafov