Get Web Browser Name In C#


The C# provides the class "HttpBrowserCapabilities" which enables server to gather the information on the capabilities of the browser that is running on the client. The HTTP browser capabilities is derived from the class"HttpCapabilitiesBase" which has the properties that give the information about client browser. When the object is created for "HttpBrowserCapabilities using "HttpContext.Current.Request.Browser", the object will have all the browser details.

 public string GetBrowserName()  
    {  
        string BrowserName = string.Empty;  
        try  
        {  
            BrowserName = HttpContext.Current.Request.Browser.Browser;  
        }  
        catch (Exception ex)  
        {  
            throw new Exception(ex.Message);  
        }  
        return BrowserName;  
    }  

#viastudy

Post a Comment

0 Comments