Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

With Blazor WebAssembly Azure cookies are coming from ARRAffinitySameSite instead of .AspNetCore.Identity.Application

$
0
0

I have an "error" [bug]

When I upload to Azure, the cookies in use are ARRAffinitySameSite

On my machine, the API and WEB work correctly locally, it comes with .AspNetCore.Identity.Application.

I'm using BLAZOR.

    program.cs in WebAssembly:    var builder = WebAssemblyHostBuilder.CreateDefault(args);    builder.RootComponents.Add<App>("#app");    builder.RootComponents.Add<HeadOutlet>("head::after");    builder.Services.AddRadzenComponents();    builder.Services.AddScoped<CookieHandler>();    builder.Services.AddAuthorizationCore();    builder.Services.AddScoped<AuthenticationStateProvider, AuthAPI>();    builder.Services.AddScoped<AuthAPI>(sp => (AuthAPI)sp.GetRequiredService<AuthenticationStateProvider>());    builder.Services.AddCascadingAuthenticationState();    builder.Services.AddScoped<Status>();    builder.Services.AddHttpClient("API", client => {        client.BaseAddress = new Uri(builder.Configuration["API:Url"]!);        //  client.BaseAddress = new Uri("https://localhost:7089/");        client.DefaultRequestHeaders.Add("Accept", "application/json");    }).AddHttpMessageHandler<CookieHandler>();    await builder.Build().RunAsync();

In the API everything seems to be normal. Because when I use PostMan or via Swagger it works normally. The problem is when I use Blazor.. In API Server :

var builder = WebApplication.CreateBuilder(args);builder.Services.AddControllers();builder.Services.AddDbContext<Context>((options) =>{    options            .UseSqlServer(builder.Configuration["ConnectionStrings:DB"])            .UseLazyLoadingProxies();});builder.Services    .AddIdentityApiEndpoints<IdentityUser>()    .AddEntityFrameworkStores<Context>();builder.Services.AddAuthentication();builder.Services.AddEndpointsApiExplorer();builder.Services.AddSwaggerGen();builder.Services.Configure<Microsoft.AspNetCore.Http.Json.JsonOptions>(options => options.SerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles);builder.Services.AddCors(    options => options.AddPolicy("wasm",        policy => policy            .AllowAnyMethod()            .SetIsOriginAllowed(pol => true)            .AllowAnyHeader()            .AllowCredentials()));var app = builder.Build();app.UseHttpsRedirection();app.UseCors("wasm");app.UseStaticFiles();app.UseCookiePolicy();app.UseAuthorization();app.MapIdentityApi<IdentityUser>().WithTags("Authorization");app.MapControllers();app.UseSwagger();app.UseSwaggerUI();app.UseMiddleware<ReadMe.Metrics>();app.Run();

I'm sharing more code to check the problem. Because it really works with localhost. It could be something in Azure that is not receiving from another URL of my API. That's why I need this help.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>