4

Is the App_Browsers folder still required in ASP.NET 4 sites/applications?

I've had this in my site for years, containing only a w3cvalidator.browser file to make the site validate in the W3C validator.

Now that Microsoft are very pro-standard, surely this is redundant? I've searched today but can only find pages that are years old.

EvilDr
  • 8,943
  • 14
  • 73
  • 133

1 Answers1

3

The App_Browsers folder is still used. According to MSDN:

Contains browser definitions (.browser files) that ASP.NET uses to identify individual browsers and determine their capabilities.

This system is still in place and can be used to generate different output for mobile for example too, so still useful.

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
  • Thanks for that. I had seen this page in MSDN, but am unsure how it still relates to web design when everyone is aiming at standards-compliant code. Is it still used so that older browsers can be supported? What other reasons would it be used for please? I'm sure I read a long time ago on Scott Hansleman's blog that browsercap-related stuff should now be avoided, but I can't find it – EvilDr Jun 03 '14 at 09:48
  • 1
    That might be true, but if you have specific wishes, like (embedded) browsers that do not fully support some features, or render the same controls differently on mobile vs full web, this *is* an option. Whether it is the best depends on the specific situation. – Patrick Hofman Jun 03 '14 at 09:49
  • So if I only target the main browsers (e.g. IE8+, FF20+ etc) then it would probably safe to delete it? Does ASP.NET now recognise the W3C validator without a specific reference to it within `App_Browsers`? – EvilDr Jun 03 '14 at 09:59
  • 1
    @EvilDr: Why should it recognize the W3C validator? Will the output differ only for validation? (According to http://thibautvs.com/blog/?p=1346 it does). So then you still need it because ASP.NET does not generate the proper code for the validator (since they use an unknown browser). I would give it a try to delete it. Run it through the validator, check! – Patrick Hofman Jun 03 '14 at 10:02
  • Rather than take the app offline and redeploy, I used User Agent Switcher for Firefox and amended it to `W3C_Validator/1.3`. Upon reloading (and checking this `User-Agent` *was* sent with the request, the new source code did validate when posted to W3C. It seems that ASP.NET does now recognise the W3C User-Agent without the .browser file being required. I will do further testing however when its convenient to update my live app. – EvilDr Jun 03 '14 at 10:22
  • @EvilDr: Good luck with that. Thanks for coming back on the results. Love to hear the end result. – Patrick Hofman Jun 03 '14 at 10:23
  • Argh scrap that! If you change the `User Agent`, most of the ASP.NET JavaScript breaks (`WebForm_DoPostBackWithOptions is not defined`). Others are also reporting that .browser files are needed for IE11 here http://stackoverflow.com/questions/18244223/webform-dopostbackwithoptions-is-undefined-in-ie11-preview so I'm leaving it in for now to save unnecessary headaches. – EvilDr Jun 03 '14 at 11:09
  • I use this asp.net functionality, with the browser set to default. This allows me to put a function in the path for every page, so that I can log all the pages visited, including the visitors IP address. This is so useful for forensics. – Steve Hibbert Aug 18 '16 at 13:57