Indorsoft.YandexSmartCaptcha 0.0.1

dotnet add package Indorsoft.YandexSmartCaptcha --version 0.0.1
NuGet\Install-Package Indorsoft.YandexSmartCaptcha -Version 0.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Indorsoft.YandexSmartCaptcha" Version="0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Indorsoft.YandexSmartCaptcha --version 0.0.1
#r "nuget: Indorsoft.YandexSmartCaptcha, 0.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Indorsoft.YandexSmartCaptcha as a Cake Addin
#addin nuget:?package=Indorsoft.YandexSmartCaptcha&version=0.0.1

// Install Indorsoft.YandexSmartCaptcha as a Cake Tool
#tool nuget:?package=Indorsoft.YandexSmartCaptcha&version=0.0.1

Yandex SmartCaptcha для .NET

Данный проект не является официальной библиотекой Yandex Cloud

Зависимости

Refit

Проект YandexSmartCaptcha.AspNetCore содержит интерфейс ISmartCaptchaApi для использования с библиотекой Refit. Refit — проект с открытым исходным кодом для типобезопасносного обращения к конечным точкам REST, предоставленным Yandex SmartCaptcha.

Если вы не хотите использовать Refit, вы можете создать собственную реализация интерфейса ISmartCaptchaApi или использовать SmartCaptcha без этого проекта.

Использование в ASP.NET Core

1) Настройки

Конфигурация представления в виде класса SmartCaptchaOptions. Некоторые значения предзаданы текущими значениями по умолчанию Yandex SmartCaptcha. SiteKey и ServerKey должны быть заданы для работы.

Самым лёгким способом является использование настроек .NET Core через appsettings.json

"SmartCaptcha": {
   "SiteKey": "", // Заполните поля вашей парой ключей
   "ServerKey": ""
}

и регистрация через AddSmartCaptcha, которая является частью YandexSmartCaptcha.AspNetCore.

public void ConfigureServices(IServiceCollection services)
{
   // Yandex SmartCaptcha
   services.AddSmartCaptcha(Configuration.GetSection("SmartCaptcha"));
   ...

2) Регистрация Model Binder

В настоящее время библиотека ASP.NET core даёт возможность автоматизировать интеграцию SmartCaptcha. Для этих целей применяется ModelBinder, которая используется если SmartCaptchaVerifyResponse является одним из передаваемых аргументов в action.

Вы должны зарегистрировать Model Binder

public void ConfigureServices(IServiceCollection services)
{
   // Yandex SmartCaptcha
   services.AddSmartCaptcha(Configuration.GetSection("SmartCaptcha"));

    // Mvc
    services.AddControllersWithViews(mvcOptions =>
        // добавление model binder
        mvcOptions.AddSmartCaptchaModelBinder());
}

И ваш Action:

public class HomeController : Controller
{
    [HttpGet, Route("")]
    public IActionResult Index()
    {
        return View(new IndexViewModel());
    }

    [HttpPost, Route("")]
    public IActionResult Index(SmartCaptchaVerifyResponse smartCaptcha)
    {
        return View(new IndexViewModel(smartCaptcha));
    }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Indorsoft.YandexSmartCaptcha:

Package Downloads
Indorsoft.YandexSmartCaptcha.AspNetCore

This inofficial client library enables working with Yandex's SmartCaptcha with ASP.NET Core.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.1 675 9/30/2022