Skip to content

GetBrowserOptions(HttpContext) usage in #68815 does not match the shipped API invocation #69045

Closed

Description

@irfanajaffer

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

The validation scenario in #68815 says:

BrowserOptions.GetBrowserOptions(httpContext) reads what is currently in effect.

Following that notation and calling GetBrowserOptions on the BrowserOptions instance supplied to WithBrowserOptions(...) fails with compiler error CS1061:

'BrowserOptions' does not contain a definition for 'GetBrowserOptions' and no accessible extension method 'GetBrowserOptions' accepting a first argument of type 'BrowserOptions' could be found (are you missing a using directive or an assembly reference?)

The API is present in .NET SDK 11.0.100-preview.7.26381.103, but it is exposed as:

Microsoft.AspNetCore.Components.BrowserOptionsHttpContextExtensions.GetBrowserOptions(HttpContext)

The working extension-method invocation is:

using Microsoft.AspNetCore.Components;

var effectiveOptions = httpContext.GetBrowserOptions();

The Microsoft.AspNetCore.Components namespace is required because it is not included by the Web SDK's implicit usings.

Expected Behavior

The validation scenario should show the supported invocation and required namespace so testers can read the effective merged BrowserOptions without interpreting BrowserOptions as the method receiver.

For example:

using Microsoft.AspNetCore.Components;

BrowserOptions effectiveOptions = httpContext.GetBrowserOptions();

Alternatively, the issue could name the declaring extension class explicitly:

BrowserOptionsHttpContextExtensions.GetBrowserOptions(httpContext);

Steps To Reproduce

  1. Use .NET SDK 11.0.100-preview.7.26381.103.
  2. Create a Blazor Web App targeting net11.0.
  3. Configure endpoint-level browser options and follow the notation from [Validation] Setting BrowserOptions from server code #68815 by calling the method on the callback's BrowserOptions parameter:
app.MapRazorComponents<App>()
    .AddInteractiveServerRenderMode()
    .WithBrowserOptions(options =>
    {
        options.LogLevel = LogLevel.Warning;
      options.GetBrowserOptions(default!);
    });
  1. Build the project.
  2. Observe compiler error CS1061 on options.GetBrowserOptions(...).
  3. Replace the call with the supported invocation and import its namespace:
using Microsoft.AspNetCore.Components;

var effectiveOptions = httpContext.GetBrowserOptions();
  1. Build again and observe that the project compiles successfully.

Minimal project configuration:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>net11.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>
</Project>

Exceptions (if any)

No runtime exception occurs. The incorrect receiver produces compiler error CS1061.

Without using Microsoft.AspNetCore.Components;, calling httpContext.GetBrowserOptions() also produces CS1061 because the extension method is not in scope.

.NET Version

11.0.100-preview.7.26381.103

Anything else?

Test environment:

  • Windows 11
  • .NET SDK 11.0.100-preview.7.26381.103
  • Target framework net11.0
  • ASP.NET Core shared framework supplied by the SDK; no additional package references

Reproduction and validation repository:

The Preview 7 reference documentation contains:

M:Microsoft.AspNetCore.Components.BrowserOptionsHttpContextExtensions.GetBrowserOptions(Microsoft.AspNetCore.Http.HttpContext)

The supported call was verified in the reproduction project: httpContext.GetBrowserOptions() compiles with zero warnings and zero errors after importing Microsoft.AspNetCore.Components.

Activity

  1. added theissue type on Sep 4, 2026
  2. added
    area-blazor
    on Sep 4, 2026
  3. github-actions commented on Sep 4, 2026

    @github-actions
    Contributor

    Triage Summary

    Area: area-blazor (issue concerns BrowserOptions/GetBrowserOptions API used with MapRazorComponents().WithBrowserOptions(...))
    Type: Bug (preserved)

    Potential Duplicates

    • None found

    Generated by Issue Triage Agent for dotnet/aspnetcore for #69045 · copilot · auto · 34.9 AIC · ⌖ 20.8 AIC · ⊞ 29.6K · ◷

  4. Youssef1313 commented on Sep 4, 2026

    @Youssef1313
    Member

    The instructions are correct for RC1 and later. The BrowserOptions.GetBrowserOptions method was added in #67918, and BrowserOptionsHttpContextExtensions.GetBrowserOptions got removed.

  5. removed theissue type on Sep 4, 2026
  6. added theissue type on Sep 4, 2026
  7. Youssef1313 commented on Sep 4, 2026

    @Youssef1313
    Member

    @oroztocil Maybe consider updating the scenario description to require at least RC1 (not released yet).

    @irfanajaffer Would you generally be able to test the scenarios with RC1? If not, I think we can help get you setup an RC1 build.

  8. irfanajaffer commented on Sep 4, 2026

    @irfanajaffer
    ContributorAuthor

    @Youssef1313 ,

    I was able to validate the scenario using an RC build. The application was tested on .NET SDK 11.0.100-rc.2.26453.114, and the shipped API BrowserOptions.GetBrowserOptions(HttpContext) is available and functioning as expected.

    Validation confirmed both compile-time and runtime availability:

    Project builds successfully with no errors.
    BrowserOptions.GetBrowserOptions(HttpContext) resolves correctly.
    Runtime verification returned the expected BrowserOptions instance.

    I have also hosted the updated sample in the repository and used it for the validation scenarios.

    Based on the validation results, the scenario remains applicable for RC1 and later releases, with the only change being the API transition from httpContext.GetBrowserOptions() to BrowserOptions.GetBrowserOptions(HttpContext).

  9. Youssef1313 commented on Sep 4, 2026

    @Youssef1313
    Member

    @irfanajaffer Thanks for confirming that you could validate the scenario. Is there anything else for this issue or should we close it?

  10. irfanajaffer commented on Sep 4, 2026

    @irfanajaffer
    ContributorAuthor

    @Youssef1313 ,

    We have completed the validation, verified the required APIs in the RC build, and successfully tested the pending scenario. We do not have any remaining concerns or action items for this issue.

    We can close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-blazor

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions