Learn More, Pay Less!
Limited Time Offer!

Activities of "liangshiwei"

This is reasonable; I created an issue for discussion with the team.

Hi,

Unfortunately, there is no such feature at the moment; our repository is internal.

The PR has been merged. You should see it in the next update

Hi,

I am using the latest template and don't have this problem.

See https://learn.microsoft.com/en-us/aspnet/core/mvc/views/partial?view=aspnetcore-9.0

A partial view is a Razor markup file (.cshtml) without a @page directive that renders HTML output within another markup file's rendered output.

HI,

Try remove @page from First and Second Page

Hi,

I didn't find a standard way to solve this. you can see even Microsoft's examples are using httpContextAccessor.

https://github.com/dotnet/blazor-samples/blob/main/9.0/BlazorWebAppOidcBff/BlazorWebAppOidc/ServerWeatherForecaster.cs#L11

We need to wait for the Azure SignalR team to provide a better explanation.

https://github.com/dotnet/AspNetCore.Docs/issues/13508

you can try this as a temporary solution:

public class AzureSignalRCookieService : ISingletonDependency
{
    public string Cookies { get; set; }
}

[Dependency(ReplaceServices = true)]
public class MyBlazorServerLookupApiRequestService : ILookupApiRequestService, ITransientDependency
{
    public IHttpClientFactory HttpClientFactory { get; }
    public IRemoteServiceHttpClientAuthenticator HttpClientAuthenticator { get; }
    public IRemoteServiceConfigurationProvider RemoteServiceConfigurationProvider { get; }
    public ICurrentTenant CurrentTenant { get; }
    public IHttpContextAccessor HttpContextAccessor { get; }
    public NavigationManager NavigationManager { get; }
    
    public AzureSignalRCookieService SignalRCookieService { get; }
    
    public MyBlazorServerLookupApiRequestService(IHttpClientFactory httpClientFactory,
        IRemoteServiceHttpClientAuthenticator httpClientAuthenticator,
        ICurrentTenant currentTenant,
        IHttpContextAccessor httpContextAccessor,
        NavigationManager navigationManager,
        IRemoteServiceConfigurationProvider remoteServiceConfigurationProvider,
        AzureSignalRCookieService signalRCookieService)
    {
        HttpClientFactory = httpClientFactory;
        HttpClientAuthenticator = httpClientAuthenticator;
        CurrentTenant = currentTenant;
        HttpContextAccessor = httpContextAccessor;
        NavigationManager = navigationManager;
        RemoteServiceConfigurationProvider = remoteServiceConfigurationProvider;
        SignalRCookieService = signalRCookieService;
    }

    public async Task<string> SendAsync(string url)
    {
        var client = HttpClientFactory.CreateClient(nameof(BlazorServerLookupApiRequestService));
        var requestMessage = new HttpRequestMessage(HttpMethod.Get, url);

        var uri = new Uri(url, UriKind.RelativeOrAbsolute);
        if (!uri.IsAbsoluteUri)
        {
            var remoteServiceConfig = await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultOrNullAsync("Default");
            if (remoteServiceConfig != null)
            {
                // Blazor tiered mode
                var baseUrl = remoteServiceConfig.BaseUrl;
                client.BaseAddress = new Uri(baseUrl);
                AddHeaders(requestMessage);
                await HttpClientAuthenticator.Authenticate(new RemoteServiceHttpClientAuthenticateContext(client, requestMessage, new RemoteServiceConfiguration(baseUrl), string.Empty));
            }
            else
            {
                // Blazor server  mode
                client.BaseAddress = new Uri(NavigationManager.BaseUri);
                var request = HttpContextAccessor.HttpContext?.Request;
                if (request != null)
                {
                    foreach (var header in HttpContextAccessor.HttpContext!.Request.Headers)
                    {
                        requestMessage.Headers.TryAddWithoutValidation(header.Key, header.Value.ToArray());
                    }
                }
                else
                {
                    requestMessage.Headers.TryAddWithoutValidation("Cookie", SignalRCookieService.Cookies);
                }
            }
        }

        var response = await client.SendAsync(requestMessage);
        return await response.Content.ReadAsStringAsync();
    }

    protected virtual void AddHeaders(HttpRequestMessage requestMessage)
    {
        if (CurrentTenant.Id.HasValue)
        {
            requestMessage.Headers.Add(TenantResolverConsts.DefaultTenantKey, CurrentTenant.Id.Value.ToString());
        }

        var currentCulture = CultureInfo.CurrentUICulture.Name ?? CultureInfo.CurrentCulture.Name;
        if (!currentCulture.IsNullOrEmpty())
        {
            requestMessage.Headers.AcceptLanguage.Add(new(currentCulture));
        }
    }
}
app.Use((httpContext, next) =>
{
    httpContext.RequestServices.GetRequiredService<AzureSignalRCookieService>().Cookies = httpContext.Request.Cookies.Select(x => $"{x.Key}={x.Value}").JoinAsString("; ");
    return next();
});

Hi,

can you describe it in detail?

thanks.

https://github.com/abpframework/abp/issues/21915

Hi,

This is reasonable, we will fix it. your ticket was refunded.

Answer

Hi,

It seems like a problem, I will check it.

Showing 81 to 90 of 6574 entries
Made with ❤️ on ABP v9.2.0-preview. Updated on February 17, 2025, 05:40