怎么在asp.net核心中接入腾讯验证码

  介绍

这期内容当中小编将会给大家带来有关怎么在asp.net核心中接入腾讯验证码,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

<强>验证流程

服务器端接入

using  System.ComponentModel.DataAnnotations;   using  System.Net.Http;   using  System.Threading.Tasks;   using  Microsoft.Extensions.Logging;   using  Microsoft.Extensions.Options;   using  Newtonsoft.Json;   using  WeihanLi.Extensions;      namespace  ActivityReservation.Common   {   public 才能;class  TencentCaptchaOptions   {才能   ,,,///,& lt; summary>   ,,,///,客户端AppId   ,,,///,& lt;/summary>   ,,,(要求)   ,,,public  string  AppId {组,得到,,,}      ,,,///,& lt; summary>   ,,,///,App  Secret 关键   ,,,///,& lt;/summary>   ,,,(要求)   ,,,public  string  AppSecret {组,得到,,,}   ,,}      public 才能;class  TencentCaptchaRequest   {才能   ,,,///,& lt; summary>   ,,,///,验证码客户端验证回调的票据   ,,,///,& lt;/summary>   ,,,public  string  Ticket {组,得到,,,}      ,,,///,& lt; summary>   ,,,///,验证码客户端验证回调的随机串   ,,,///,& lt;/summary>   ,,,public  string  Nonce {组,得到,,,}      ,,,///,& lt; summary>   ,,,///,提交验证的用户的IP地址(如:10.127.10.2)   ,,,///,& lt;/summary>   ,,,public  string  UserIP {组,得到,,,}   ,,}      public 才能;class  TencentCaptchaHelper   {才能   ,,,private  class  TencentCaptchaResponse   ,,,{   ,,,,,///,& lt; summary>   ,,,,,///,1:验证成功,0:验证失败,100:AppSecretKey参数校验错误   ,,,,,///,& lt;/summary>   ,,,,,(JsonProperty (“response")]   ,,,,,public  int  Code {组,得到,,,}      ,,,,,///,& lt; summary>   ,,,,,///,恶意等级,[0,100)   ,,,,,///,& lt;/summary>   ,,,,,(JsonProperty (“evil_level")]   ,,,,,public  string  EvilLevel {组,得到,,,}      ,,,,,///,& lt; summary>   ,,,,,///,错误信息   ,,,,,///,& lt;/summary>   ,,,,,(JsonProperty (“err_msg")]   ,,,,,public  string  ErrorMsg {组,得到,,,}   ,,,}      ,,,private  const  string  TencentCaptchaVerifyUrl =,“https://ssl.captcha.qq.com/ticket/verify";   ,,,private  readonly  TencentCaptchaOptions  _captchaOptions;   ,,,private  readonly  ILogger  _logger;   ,,,private  readonly  HttpClient  _httpClient;      ,,,public  TencentCaptchaHelper (   ,,,,,IOptions,选项,   ,,,,,ILogger,记录器,   ,,,,,HttpClient  httpClient)   ,,,{   ,,,,,_captchaOptions =, option.Value;   ,,,,,_logger =,记录器;   ,,,,,_httpClient =, httpClient;   ,,,}      ,,,public  async  Task, IsValidRequestAsync (TencentCaptchaRequest 请求)   ,,,{   ,,,,,//,参考文档:https://007.qq.com/captcha//gettingStart   ,,,,,var  response =, await  _httpClient.GetAsync (   ,,,,,,,美元“{TencentCaptchaVerifyUrl} ?援助={_captchaOptions.AppId}, AppSecretKey={_captchaOptions.AppSecret},票={request.Ticket}, Randstr={request.Nonce}, UserIP={request.UserIP}“);   ,,,,,var  responseText =, await  response.Content.ReadAsStringAsync ();   ,,,,,if  (responseText.IsNotNullOrEmpty ())   ,,,,,{   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

怎么在asp.net核心中接入腾讯验证码