Repository navigation
ArgumentNullException in Blazor #2740
Unanswered
Jeff Haynes (jefffhaynes)
asked this question in
Q&A
Replies: 4 comments 4 replies
|
Jeff Haynes (@jefffhaynes), assuming this is the new Blazor app in .NET 8: |
0 replies
|
Thanks for the questions Jean-Marc Prieur (@jmprieur). My goal is to use all RBAC/SSO so no client secrets. Here is my entire program.cs. This is all being done as an App Service. I have not tried it locally (at least not this part). var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd"))
.EnableTokenAcquisitionToCallDownstreamApi()
.AddMicrosoftGraph(options => options.RequestAppToken = true)
.AddInMemoryTokenCaches();
builder.Services.AddControllersWithViews(options =>
{
var policy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
options.Filters.Add(new AuthorizeFilter(policy));
}).AddMicrosoftIdentityUI();
builder.Services.AddMicrosoftIdentityConsentHandler();
builder.Services.AddDbContextFactory<MyContext>(options =>
{
options.UseCosmos("<url>",
new DefaultAzureCredential(), MyContext.DatabaseName);
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseAntiforgery();
app.UseAuthentication();
app.UseAuthorization();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
app.Run(); |
0 replies
|
Jean-Marc Prieur (@jmprieur) do you see any obvious problems with what I'm doing? |
0 replies
|
It seems that the app service does not provide you with headers. |
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I'm sure I'm missing something obvious but I'm getting an ArgumentNullException in Blazor (.NET 8) when I try to use the
GraphServiceClientinOnParametersSetAsync:The exception takes place the second time
OnParametersSetAsyncis called during the render cycle. The first time the call completes successfully.I'm initializing like this:
All reactions