From 3077f3bbce1877cbda71aaa64ac6f982d56bd33d Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Sun, 17 Mar 2024 15:07:09 +0330 Subject: [PATCH 1/2] fixed UrlHelper not finding controller with modified name Bug --- src/DNTCaptcha.Core/DNTCaptchaApiProvider.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/DNTCaptcha.Core/DNTCaptchaApiProvider.cs b/src/DNTCaptcha.Core/DNTCaptchaApiProvider.cs index e111b24..c517a98 100644 --- a/src/DNTCaptcha.Core/DNTCaptchaApiProvider.cs +++ b/src/DNTCaptcha.Core/DNTCaptchaApiProvider.cs @@ -113,15 +113,19 @@ private string getCaptchaImageUrl(DNTCaptchaTagHelperHtmlAttributes captchaAttri var encryptSerializedValues = _captchaProtectionProvider.Encrypt(_serializationProvider.Serialize(values)); + string controllerName = nameof(DNTCaptchaImageController).Replace("Controller", string.Empty, StringComparison.Ordinal); + if (!String.IsNullOrEmpty(_captchaOptions.CaptchaImageControllerNameTemplate)) + controllerName = _captchaOptions.CaptchaImageControllerNameTemplate; + var actionUrl = captchaAttributes.UseRelativeUrls ? _urlHelper.Action(nameof(DNTCaptchaImageController.Show), - nameof(DNTCaptchaImageController).Replace("Controller", string.Empty, StringComparison.Ordinal), new + controllerName, new { data = encryptSerializedValues, area = "" }) : _urlHelper.Action(nameof(DNTCaptchaImageController.Show), - nameof(DNTCaptchaImageController).Replace("Controller", string.Empty, StringComparison.Ordinal), new + controllerName, new { data = encryptSerializedValues, area = "" From 0b5a64909769d2696cba35645423c2373a5ff16d Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Sun, 17 Mar 2024 17:37:41 +0330 Subject: [PATCH 2/2] updated readme --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index e412558..5883f92 100644 --- a/README.md +++ b/README.md @@ -219,6 +219,12 @@ namespace DNTCaptcha.TestWebApp.Controllers } ``` +- If you use `Swagger` make sure to install [Swashbuckle.AspNetCore.SwaggerGen.ConventionalRouting](https://github.com/chsakell/Swashbuckle.AspNetCore.SwaggerGen.ConventionalRouting) Nuget Package and add it like so: + +```csharp +services.AddSwaggerGenWithConventionalRoutes(); +``` + ## How to choose a correct storage mode If your environment is distributed and you are using a `Session (UseSessionStorageProvider())`