Activities of "LiSong"

Answer

still not working, pls take a look:

using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using System.Threading.Tasks; using System; using Volo.Abp.DistributedLocking; using Medallion.Threading;

namespace Tapp.Web.Pages;

public class IndexModel : TappPageModel { private readonly IAbpDistributedLock _distributedLock; private readonly IDistributedLockProvider _distributedLockProvider; private readonly ILogger<IndexModel> _logger;

public IndexModel(IAbpDistributedLock distributedLock, IDistributedLockProvider distributedLockProvider, ILogger&lt;IndexModel&gt; logger)
{
    _distributedLock = distributedLock;
    _distributedLockProvider = distributedLockProvider;
    _logger = logger;
}

public string LockTestResult { get; set; }
public virtual async Task&lt;IActionResult&gt; OnGetAsync()
{
    await RunLockTestAsync();
    return Page();
}

private async Task RunLockTestAsync()
{
    var currentUserId = Guid.NewGuid(); // For testing, generate a dummy user id
    var lockKey = $"form-submission-lock:";
    for (int i = 0; i &lt; 3; i++)
    {
        await using var handle = await _distributedLock.TryAcquireAsync(lockKey, TimeSpan.FromSeconds(5));
        if (handle != null)
        {
            await DummyCriticalSection();
            _logger.LogInformation(&quot;Lock acquired and dummy section executed.&quot;);
            //return &quot;Lock acquired and dummy section executed.&quot;;
        }
        else
        {
            _logger.LogWarning(&quot;Could not acquire lock, retrying...&quot;);
        }

    }
    _logger.LogError(&quot;Could not acquire lock after 3 attempts.&quot;);
    //return &quot;Could not acquire lock after 3 attempts.&quot;;
}

private async Task DummyCriticalSection()
{
    await Task.Delay(1000); // Simulate work
}

}

<ItemGroup> <PackageReference Include="AspNetCore.HealthChecks.UI" Version="9.0.0" /> <PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="9.0.0" /> <PackageReference Include="DistributedLock.Core" Version="1.0.8" /> <PackageReference Include="DistributedLock.Redis" Version="1.0.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.0" /> <PackageReference Include="AspNetCore.HealthChecks.UI.InMemory.Storage" Version="9.0.0" /> <PackageReference Include="Serilog.AspNetCore" Version="9.0.0" /> <PackageReference Include="Serilog.Sinks.Async" Version="2.1.0" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="9.0.0" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="9.0.0" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.Twitter" Version="9.0.0" /> <PackageReference Include="StackExchange.Redis" Version="2.8.58" /> <PackageReference Include="Volo.Abp.DistributedLocking" Version="9.0.4" /> </ItemGroup>

Answer

just sent you an email with the project thanks

Answer

I have set up the breakpoints, and I confirm

the Type of _distributedLock is MedallionAbpDistributedLock.

the IDistributedLockProvider is RedisDistributedSynchronizationProvider

but the lock still doesnt work

Answer

thanks I am checking

Question

I need to use locking

I wrote a function and then called it three time in order to test it

cs
public async Task<IActionResult> InsertFormAnswerJson(Guid id, [FromBody] JsonElement json)
{
    var key = $"test-{id}";
    await _submissionLockCache.GetOrAddAsync(key, async () =>
    {
        // Simulate some processing
        await Task.Delay(100);
        return "test-value";
    }, () => new DistributedCacheEntryOptions
    {
        AbsoluteExpiration = Constants.RedisConstants.CacheExpiration
    });
   var value = await _submissionLockCache.GetAsync(key);
    var jsonString = json.GetRawText();
    var currentUserId = _currentUser.Id;

    if (currentUserId == null)
    {
        return Unauthorized();
    }

    var lockKey = $"form-submission-lock:{currentUserId}:{id}";

    await using var handle =
        await _distributedLock.TryAcquireAsync(lockKey,TimeSpan.FromSeconds(1));
    if (handle != null)
    {
        try
        {
            _logger.LogInformation($"form-submission:{currentUserId}:{id}");
            await _resultAnswerService.SaveUserAnswerAsync(id, currentUserId.Value, jsonString);
            return Ok();
        }
        catch (Exception ex)
        {
            return StatusCode(500, "An error occurred while processing your submission.");
        }

    }
    _logger.LogInformation($"form-submission[duplicate]:{currentUserId}:{id}");
    return StatusCode(429, "Duplicate submission detected. Please wait a moment before retrying.");
}

the locking didnt work
I have a line on the top _submissionLockCache.GetOrAddAsync to test the redis, so the redis is working properly , and the lock timeout should be just 1 sec.

2025-07-17 14:15:09.180 -07:00 [Information] Route matched with "{action = \"InsertFormAnswerJson\", controller = \"DataConnectionForm\", area = \"\", page = \"\"}". Executing controller action with signature "System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] InsertFormAnswerJson(System.Guid, System.Text.Json.JsonElement)" on controller "Tapp.Module.DataHub.Web.Controllers.DataConnections.DataConnectionFormController" ("Tapp.Module.DataHub.Web").
2025-07-17 14:15:25.215 -07:00 [Information] form-submission:fcc9c058-7590-4b02-f5a6-3a190bb27c6b:4ef0a401-5951-82b7-3d90-3a1adefa39ec
2025-07-17 14:15:26.529 -07:00 [Information] Start processing HTTP request "GET" "https://localhost:44381/health-status"
2025-07-17 14:15:26.529 -07:00 [Information] Sending HTTP request "GET" "https://localhost:44381/health-status"
2025-07-17 14:15:26.529 -07:00 [Information] Request starting "HTTP/1.1" "GET" "https"://"localhost:44381""""/health-status""" - null null
2025-07-17 14:15:26.532 -07:00 [Information] Executing endpoint '"Health checks"'
2025-07-17 14:15:26.711 -07:00 [Information] Executing StatusCodeResult, setting HTTP status code 200
2025-07-17 14:15:26.711 -07:00 [Information] Executed action "Tapp.Module.DataHub.Web.Controllers.DataConnections.DataConnectionFormController.InsertFormAnswerJson (Tapp.Module.DataHub.Web)" in 17530.5898ms
2025-07-17 14:15:26.711 -07:00 [Information] Executed endpoint '"Tapp.Module.DataHub.Web.Controllers.DataConnections.DataConnectionFormController.InsertFormAnswerJson (Tapp.Module.DataHub.Web)"'
2025-07-17 14:15:27.027 -07:00 [Information] Request finished "HTTP/2" "POST" "https"://"localhost:44381""""/api/data-connections/forms/4ef0a401-5951-82b7-3d90-3a1adefa39ec/answers""" - 200 null null 18225.3835ms
2025-07-17 14:15:27.213 -07:00 [Information] form-submission:fcc9c058-7590-4b02-f5a6-3a190bb27c6b:4ef0a401-5951-82b7-3d90-3a1adefa39ec
2025-07-17 14:15:27.388 -07:00 [Information] Executing StatusCodeResult, setting HTTP status code 200
2025-07-17 14:15:27.388 -07:00 [Information] Executed action "Tapp.Module.DataHub.Web.Controllers.DataConnections.DataConnectionFormController.InsertFormAnswerJson (Tapp.Module.DataHub.Web)" in 18207.493ms
2025-07-17 14:15:27.388 -07:00 [Information] Executed endpoint '"Tapp.Module.DataHub.Web.Controllers.DataConnections.DataConnectionFormController.InsertFormAnswerJson (Tapp.Module.DataHub.Web)"'
2025-07-17 14:15:27.536 -07:00 [Information] form-submission:fcc9c058-7590-4b02-f5a6-3a190bb27c6b:4ef0a401-5951-82b7-3d90-3a1adefa39ec
2025-07-17 14:15:27.625 -07:00 [Information] Request finished "HTTP/2" "POST" "https"://"localhost:44381""""/api/data-connections/forms/4ef0a401-5951-82b7-3d90-3a1adefa39ec/answers""" - 200 null null 18823.4763ms
2025-07-17 14:15:27.635 -07:00 [Information] Request starting "HTTP/2" "GET" "https"://"localhost:44381""""/""?dataconnection=4ef0a401-5951-82b7-3d90-3a1adefa39ec" - null null
2025-07-17 14:15:27.655 -07:00 [Information] Executing endpoint '"/Index"'

how can I fix it?

I read this doc https://abp.io/docs/9.2/framework//infrastructure/distributed-locking

Question

I want to set up CI/CD with GitHub Actions to deploy your Web and public.web apps to Azure App Services, I am currently using VS publish.

and I had an old one set up before and I found some errors:

un dotnet build src/Tapp.Web/Tapp.Web.csproj --configuration Release Determining projects to restore... D:\a\tapp-9\tapp-9\src\Tapp.Domain\Tapp.Domain.csproj : warning NU1504: Duplicate 'PackageReference' items found. Remove the duplicate items or use the Update functionality to ensure a consistent restore behavior. The duplicate 'PackageReference' items are: Volo.Saas.Domain 9.1.0, Volo.Saas.Domain 9.1.0. D:\a\tapp-9\tapp-9\src\Tapp.HttpApi\Tapp.HttpApi.csproj : error NU1101: Unable to find package Volo.Abp.Identity.Pro.HttpApi. No packages exist with this id in source(s): nuget.org. PackageSourceMapping is enabled, the following source(s) were not considered: ABP Commerc ..... following source(s) were not considered: ABP Commercial NuGet Source, Microsoft Visual Studio Offline Packages. D:\a\tapp-9\tapp-9\src\Tapp.Web\Tapp.Web.csproj : error NU1101: Unable to find package Volo.Abp.LanguageManagement.Domain.Shared. No packages exist with this id in source(s): nuget.org. PackageSourceMapping is enabled, the following source(s) were not considered: ABP Commercial NuGet Source, Microsoft Visual Studio Offline Packages. D:\a\tapp-9\tapp-9\src\Tapp.Web\Tapp.Web.csproj : error NU1101: Unable to find package Volo.FileManagement.Domain.Shared. No packages exist with this id in source(s): nuget.org. PackageSourceMapping is enabled, the following source(s) were not considered: ABP Commercial NuGet Source, Microsoft Visual Studio Offline Packages. D:\a\tapp-9\tapp-9\src\Tapp.Web\Tapp.Web.csproj : error NU1101: Unable to find package Volo.Saas.Domain.Shared. No packages exist with this id in source(s): nuget.org. PackageSourceMapping is enabled, the following source(s) were not considered: ABP Commercial NuGet Source, Microsoft Visual Studio Offline Packages. D:\a\tapp-9\tapp-9\src\Tapp.Web\Tapp.Web.csproj : error NU1101: Unable to find package Volo.Abp.TextTemplateManagement.Domain.Shared. No packages exist with this id in source(s): nuget.org. PackageSourceMapping is enabled, the following source(s) were not considered: ABP Commercial NuGet Source, Microsoft Visual Studio Offline Packages. D:\a\tapp-9\tapp-9\src\Tapp.Web\Tapp.Web.csproj : error NU1101: Unable to find package Volo.Abp.Gdpr.Domain.Shared. No packages exist with this id in source(s): nuget.org. PackageSourceMapping is enabled, the following source(s) were not considered: ABP Commercial NuGet Source, Microsoft Visual Studio Offline Packages. D:\a\tapp-9\tapp-9\src\Tapp.Web\Tapp.Web.csproj : error NU1101: Unable to find package Volo.CmsKit.Pro.Domain.Shared. No packages exist with this id in source(s): nuget.org. PackageSourceMapping is enabled, the following source(s) were not considered: ABP Commercial NuGet Source, Microsoft Visual Studio Offline Packages. 2 Warning(s) 529 Error(s)

the host admin has a feature to login with a tenant admin and then switch back to the original account

I need to create a new page with the same feature, that is the host admin can see some of the tenant admin accounts, and clicking one of them will lead to the tenant site as the admin; and then on the homepage, I want to add a button says back to host site.

how can I implement it by calling the existing abp framework functions?

Answer

ok. thx

Answer

I don't see the code in the whole solution, I've actually searched for 'ConfigureCors' in the entire solution but found 0 matches, do I need to add the configurecors function myself? I want to clarify this to make sure I don't override anything underlying that might compromise security. thanks

Answer

sorry, I am using a layered application and non-Tiered, I was confused by layered and tiered. do you mind also checking the layered application for me. thanks

Showing 21 to 30 of 108 entries
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.1.0-preview. Updated on October 15, 2025, 07:46