List of C# Request.Browser.Types

I need to detect the browser my users are using because display:none is utilized frequently on a website I am managing. It is crucial that we ensure users are utilizing browsers that support this CSS property.

Although Request.Browser.Type provides a string that identifies the browser being used, it does not seem to be entirely reliable (for example, Edge is identified as Chrome) and there is no definitive list available for what the string should be for each browser.

If anyone has better solutions for checking CSS property support based on the user's browser, I would greatly appreciate any suggestions!

Answer №1

In my code, I have implemented a method to accurately identify the user's browser:

string browser = Request.Browser.Browser;
//When using Edge, Request.Browser.Browser returns Chrome
//To handle this, I compare it with Request.UserAgent and check if UserAgent contains Edge
if (browser != "Edge" && Request.UserAgent.Contains("Edge"))
    browser = "Edge";

For reference, here are links displaying user agent strings for popular browsers:

Includes Chrome, IE, Opera, Safari, Firefox (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent)

Specifically shows Edge: ()

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilize a class within a Framer Motion element to incorporate animations or set initial properties

Is there a way to apply a class using Framer Motion tag in the animate and initial props? Here's an example: <motion.div initial={{ className: 'hidden' }} animate={{ className: 'visible' }} > <div>yo</div> & ...

Tips on modifying webpage content based on page size (zoom) in responsive web design using CSS

I have a good understanding of responsive design and how to set elements with relative width. My specific question is regarding the transition of the page from thisto that. Any insight on this would be greatly appreciated. Thank you in advance. ...

Retrieving dynamically created row from code-behind

My ASPX page contains a table with headings. I am dynamically adding rows to the table using JavaScript, but when trying to access these newly added rows on the server side, I can only see the heading row and not the new ones. The table always appears to h ...

Using MongoDB and C# to project a single entry from a list

Consider the following object types: class A { string id; string text; } class B { string id; int somestuff; string someotherstuff; List<A> mylist; } Now, imagine I have a collection of objects of type B. My goal is to for ...

Error in Xamarin Forms (Android): Bundle is null in OnCreate method

Currently, I am working on an Android project where I need to securely store my API keys in the Android Manifest file. To access these keys, I extract them from the bundle passed through the OnCreate method in my MainActivity class: type MainActivity () = ...

Aligning buttons using JavaScript

I'm currently working on a layout with a horizontal div where buttons (referred to as letters in the code) are being created. However, I've encountered an issue where the buttons are aligning to the left side of the div and I'm unable to cen ...

Organizing my website directories using external tools

I am dealing with a website that follows this specific structure: \ |--css | \ | |--vendors | | \ | | |--normalize.css | | |--... | | | |--styles.css | |--media-queries.css | |--js | \ | |--vendors | | \ | | |- ...

A guide on testing click-to-call browser functionality using Selenium WebDriver

On my webpage, there are 1300 numbers and I need to ensure that when I click on one of them, a browser popup window opens. From this popup, I will capture some details to verify the test is successful. I am looking for guidance on how to verify this popup ...

Achieving a Side-Along Sidebar with CSS, Fully Embracing

I'm encountering an issue with achieving 100% height using CSS. Despite my extensive search for tutorials and solutions, I haven't been able to achieve the desired results. My layout consists of a sidebar and a main column where the content will ...

When a div is covered by an if statement

One of the challenges I am facing is managing a view with multiple projects, some of which are active while others are not. In my function, if a project's deadline has passed, it displays '0' days left on the view, indicating that these are ...

Unique Selector Customization

Is there a way to style all custom elements in CSS? I am looking to make custom elements default to block display (as most browsers render them inline by default) and then adjust as needed. A potential rule I have in mind is: *::custom { display: blo ...

Personalized Membership service

I am just starting out with ASP and I'm working on a website using a custom Membership provider. I've decided to use an XML file instead of a database to store my user information. Currently, I am following this example: However, I am unsure ho ...

Creating a responsive design for a centered image with absolute positioning

I'm trying to align an image at the bottom of a div while also centering it using the following CSS: HTML: <div class="myDiv"> <img src="http://bit.ly/1gHcL8T" class="imageCenter" /> </div> CSS: .myDiv { width: 80%; height: ...

"CSS dropdown menu with the item in an open state by

I have a list of images with the names of the people they belong to displayed below each image in an unordered list (UL). When hovering over a person's name, a sentence related to that person should be revealed. Here is what it looks like: ...

Get rid of the drop-down shadow effect

Currently working on a website project for a client and looking to remove the blue "shadow" effect from the dropdown menus. I believe the code that needs editing is as shown below: .main_nav ul.sub-menu { position: absolute; top: 65px; width: ...

Auto-scroll feature malfunctioning

My auto scroll function using jQuery isn't working, here is my CSS: #convo_mes{ text-align:left; width:98%; height:80%; background:#fff; border:1px solid #000; overflow-x:auto; } And in my JavaScript: $(".mes").click(functio ...

How can I use a CSS file in PHP to conceal the folder structure?

main.css $theme->assign('css_file',SITE_URL.'styles.php?theme='.THEME_ID); $theme->display(TEMPLATES_PATH.'header.tpl'); header.tpl <link rel="stylesheet" href="{$css_file}"> styles.php include TEMPLATES_PATH. ...

What is preventing me from accessing e.RowIndex during the row edit command in the grid view?

In my ASP grid, I have set data keys with the identifier 'job_no'. To handle row editing events, I implemented an onrowedit event and stored the event parameter in 'e' as shown below: protected void gvDetails_RowUpdating(object sender ...

Generating a fictional list of items in a sequential order

I am managing a website that focuses on displaying the line of succession to the British crown. The main content of the site is structured as an ordered list using the <ol> tag. However, there is a unique challenge. Individuals occasionally drop out ...

Utilizing Material UI Grid spacing in ReactJS

I'm encountering an issue with Material UI grid. Whenever I increase the spacing above 0, the Grid does not fit the screen properly and a bottom slider is visible, allowing me to move the page horizontally slightly. Here is the simplified code snippe ...