Skip to content

Commit

Permalink
Merge pull request #177 from IPdotSetAF/controller-name-customization
Browse files Browse the repository at this point in the history
Controller name customization
  • Loading branch information
VahidN authored Mar 17, 2024
2 parents 473b50d + 0b5a649 commit 2257535
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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())`
Expand Down
8 changes: 6 additions & 2 deletions src/DNTCaptcha.Core/DNTCaptchaApiProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down

0 comments on commit 2257535

Please sign in to comment.