Aspnetcore: HttpContext.Request.Browser in asp.net core

Created on 25 Jan 2019  路  6Comments  路  Source: dotnet/aspnetcore

Is there an alternative in the asp . net core world for HttpContext.Request.Browser ? .net framework 4.7.2 has this.

If no plans, to add, would you mind sharing the rationale behind that ? recommended alternate solutions ?

Most helpful comment

Hi, the browser caps feature in ASP.NET 4.x was a server-based way of doing client feature detection. This approach is generally frowned upon in the "modern" era, where runtime client-side feature detection is preferred, using techniques such as progressive enhancement. For that reason, in addition to being a huge maintenance cost to keep the list even reasonably up-to-date, the feature was not brought forward to ASP.NET Core.

All 6 comments

Hi, the browser caps feature in ASP.NET 4.x was a server-based way of doing client feature detection. This approach is generally frowned upon in the "modern" era, where runtime client-side feature detection is preferred, using techniques such as progressive enhancement. For that reason, in addition to being a huge maintenance cost to keep the list even reasonably up-to-date, the feature was not brought forward to ASP.NET Core.

Thanks Eilon

@kshyju What alternative did you end using?

Ended up writing something which parses user agent string to do this.

There are some valid use cases where browser detection is needed (Example: a proxy server which can do specific routing based browser information). I created a light weight library to do this and published as a nuget package.

Follow steps outlined here to use it.

@tb-mtg I have published the solution I used as a nuget package. See above response.

Was this page helpful?
0 / 5 - 0 ratings