Reputation: 28803
I have an ASP.NET MVC 3 application that I want to detect what browser the user is using globally so for example if they visit: app.com/login
or app.com/organisations
etc the check will still happen.
What file would I be best putting such code in? The code should check if their browser is a certain version and if so then load a different view and layout.
so e.g.
if(browser is ie < 9)
return ('chromeFrame');
elseif (browser is ff < 4 etc)
return ('upgradeBrowser');
Can anyone point me in the right direction?
To clarify this wouldn't be a redirect rather calling different views and layout if the browser isn't correct so the url wouldn't change and it would happen on any url!
Upvotes: 1
Views: 4255
Reputation: 125498
One way to do this would be using HttpBrowserCapabilities
that is exposed on the Request
as Request.Browser
.
Be mindful however that the .browser file that is used to identify browser capabilities may not be updated as frequently as new browser versions are released.
Upvotes: 1