Accessing Controller from Blazor Page not working in Azure Web App

0 Answers 97 Views
Upload
Chris
Top achievements
Rank 1
Chris asked on 16 Mar 2023, 01:09 PM

Any idea why this would work when running locally but returns "Unauthorized" when running in a Azure Web App?  Using AAD for authentication and the Blazor Upload calls to the same controller work fine.  I tried to get the User Token when the app starts, but it is null.

                HttpClient client = ClientFactory.CreateClient();

                var response = await client.PostAsJsonAsync<UploadDataViewModel>(ToAbsoluteUrl("api/IntUpload/savenotes"), _model);

                if (response.IsSuccessStatusCode)
                {
                    ShowNotification("success", "Notes file was successfully recorded.");
                }
                else
                {
                    ShowNotification("error", "Notes file failed to upload.");
                }

 

This is what I'm using for authentication in the Program.cs file:

builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
    .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd"))

 

 

No answers yet. Maybe you can help?

Tags
Upload
Asked by
Chris
Top achievements
Rank 1
Share this question
or