Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to disable .NET browser detection?

I failed to find a way to disable the browser detection feature added by asp.net 2.0.
I want all the request to my page to be treated as if IE is requesting them.
My fix was to add an App_Browsers folder to my project and in it have the following .browser file:

<browsers>
  <browser refID="Default">
    <capabilities>
      <capability name="preferredRenderingMime" value="text/html" />
      <capability name="preferredRenderingType" value="html32" />
      <capability name="requiresFullyQualifiedRedirectUrl" value="false" />
    </capabilities>
  </browser>
</browsers>

Is there a way to turn this feature off altogether?

Thanks

like image 205
Dror Avatar asked Jan 12 '09 16:01

Dror


People also ask

Can I detect which browser is being used by a user?

When considering using the user agent string to detect which browser is being used, your first step is to try to avoid it if possible. Start by trying to identify why you want to do it. Are you trying to work around a specific bug in some version of a browser? Look, or ask, in specialized forums: you're unlikely to be the first to hit this problem.

How do I avoid using user agent detection?

If you want to avoid using user agent detection, you have options! Feature detection is where you don't try to figure out which browser is rendering your page, but instead, you check to see if the specific feature you need is available. If it's not, you use a fallback.

Is there a way to test browser support without user agent sniffing?

As the above code demonstrates, there is always a way to test browser support without user agent sniffing. There is never any reason to check the user agent string for this. Lastly, the above code snippets bring about a critical issue with cross-browser coding that must always be taken into account.

What is feature detection and how does it work?

Feature detection is where you don't try to figure out which browser is rendering your page, but instead, you check to see if the specific feature you need is available. If it's not, you use a fallback.


2 Answers

One of the more offensive parts of ASP.Net, imho. No way to just turn it off AFAIK, other than config like this.

You may be interested in Rob Eberhardt's pool of resources on the topic.

like image 174
annakata Avatar answered Nov 15 '22 11:11

annakata


You can override the browser detection by setting the ClientTarget property on the page to the choice you would like it to make (probably uplevel in your case)...

like image 22
Stobor Avatar answered Nov 15 '22 12:11

Stobor