Share via


BrowserHelpers Class

Provides a way to specify custom browser (user agent) information.

Inheritance Hierarchy

System.Object
  System.Web.WebPages.BrowserHelpers

Namespace:  System.Web.WebPages
Assembly:  System.Web.WebPages (in System.Web.WebPages.dll)

Syntax

'Declaration
<ExtensionAttribute> _
Public NotInheritable Class BrowserHelpers
'Usage
public static class BrowserHelpers
[ExtensionAttribute]
public ref class BrowserHelpers abstract sealed
[<AbstractClassAttribute>]
[<SealedAttribute>]
type BrowserHelpers =  class end
public final class BrowserHelpers

The BrowserHelpers type exposes the following members.

Methods

  Name Description
Public methodStatic member ClearOverriddenBrowser Removes any overridden user agent for the current request.
Public methodStatic member GetOverriddenBrowser Returns the browser capabilities object for the overridden browser capabilities or for the actual browser if no override has been specified.
Public methodStatic member GetOverriddenUserAgent Returns the overridden user agent value or the actual user agent string if no override has been specified.
Public methodStatic member GetVaryByCustomStringForOverriddenBrowser(HttpContext) Gets a string that varies based on the type of the browser.
Public methodStatic member GetVaryByCustomStringForOverriddenBrowser(HttpContextBase) Gets a string that varies based on the type of the browser.
Public methodStatic member SetOverriddenBrowser(HttpContextBase, String) Overrides the request's actual user agent value using the specified user agent.
Public methodStatic member SetOverriddenBrowser(HttpContextBase, BrowserOverride) Overrides the request's actual user agent value using the specified browser override information.

Top

Remarks

This class lets your application treat requests as if they were coming from a different browser (user agent) than the one that the user actually made the request from. You invoke the methods of this class using the current page context, as in the following example:

Context.SetOverriddenBrowser(BrowserOverride.Mobile)

Because you invoke the methods from the current context, you do not have to pass the context to those methods when the method expects it.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

System.Web.WebPages Namespace