Indorsoft.YandexSmartCaptcha.AspNetCore
0.0.1
dotnet add package Indorsoft.YandexSmartCaptcha.AspNetCore --version 0.0.1
NuGet\Install-Package Indorsoft.YandexSmartCaptcha.AspNetCore -Version 0.0.1
<PackageReference Include="Indorsoft.YandexSmartCaptcha.AspNetCore" Version="0.0.1" />
paket add Indorsoft.YandexSmartCaptcha.AspNetCore --version 0.0.1
#r "nuget: Indorsoft.YandexSmartCaptcha.AspNetCore, 0.0.1"
// Install Indorsoft.YandexSmartCaptcha.AspNetCore as a Cake Addin #addin nuget:?package=Indorsoft.YandexSmartCaptcha.AspNetCore&version=0.0.1 // Install Indorsoft.YandexSmartCaptcha.AspNetCore as a Cake Tool #tool nuget:?package=Indorsoft.YandexSmartCaptcha.AspNetCore&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 | Versions 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. |
-
.NETStandard 2.1
- Indorsoft.YandexSmartCaptcha (>= 0.0.1)
- Microsoft.AspNetCore.Mvc.Abstractions (>= 2.2.0)
- Microsoft.AspNetCore.Mvc.Core (>= 2.2.5)
- Microsoft.Extensions.Configuration.Abstractions (>= 6.0.0)
- Refit.HttpClientFactory (>= 6.3.2)
-
net6.0
- Indorsoft.YandexSmartCaptcha (>= 0.0.1)
- Microsoft.Extensions.Configuration.Abstractions (>= 6.0.0)
- Refit.HttpClientFactory (>= 6.3.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.0.1 | 420 | 9/30/2022 |