Skip to content

Proposal to add IsBrowser to HttpCapabilitiesBase #684

@ptuukkan

Description

@ptuukkan

Summary

Add bool IsBrowser(string browserName) method to HttpCapabilitiesBase.cs. For our use case it would be enough to just have

public bool IsBrowser(string browserName) => string.Equals(Browser, browserName, StringComparison.OrdinalIgnoreCase);

in HttpCapabilitiesBase.

But as I have understood the original implementation is hierarchical so that when running Chrome these all would return true

IsBrowser("Default")
IsBrowser("Mozilla")
IsBrowser("WebKit")
IsBrowser("Chrome")

Which approach would you like to go with?

Motivation and goals

We are migrating an ASP.NET application to CoreWebForms. We use Telerik UI and some of their components such as RadAjaxLoadingPanel depends on using System.Web.Configuration.HttpCapabilitiesBase.IsBrowser(System.String) to check if the user is running on IE 7. Adding IsBrowser to HttpCapabilitiesBase would help us greatly with the migration.

Example:

 System.MissingMethodException: Method not found: 'Boolean System.Web.Configuration.HttpCapabilitiesBase.IsBrowser(System.String)'.
	at Telerik.Web.SkinRegistrar.RegisterStyleSheetReference(ISkinnableControl control, StyleSheetReference reference, StringBuilder cssRegs, Type controlToRegisterType)

In scope

  • public bool IsBrowser(string browserName) method to HttpCapabilitiesBase

Optionally:

  • Implement AddBrowser(string browser) at BrowserCapabilitiesFactory to allow hierarchical matching
  • Unit tests for hierarchical matching

Out of scope

Optionally hierarchical matching

Risks / unknowns

Not implementing hierarchical matching can cause code to silently take another path when using SystemWeb Adapters

Examples

HttpContext.Current.Request.Browser.IsBrowser("IE")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Triage 🔍Label added to new issues which need Triage

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions