I'm developing a .NET MVC3 application.
Is there a good way to detect if the user is using a mobile browser in the view (using RAZOR). I'm wanting to differ the display logic if it's a mobile browser.
Thanks!
I'm developing a .NET MVC3 application.
Is there a good way to detect if the user is using a mobile browser in the view (using RAZOR). I'm wanting to differ the display logic if it's a mobile browser.
Thanks!
The built in browser detection capabilities are no longer being kept up to date. Take a look at Scott Hanselman's blog - refer to the "More to Come" section at the bottom for details.
From that article:
I suggest taking a look at 51Degrees.mobi for more accurate detection. Also see the Steve Sanderson blog that Hanselman references for how to implement this in MVC3.
MVC3 exposes an IsMobileDevice flag in the Request.Browser object.
So in your razor code, you can query this variable and render accordingly.
For example, in your view (razor):
I use this Method (Works fine for Me)
I suggest you to use responsive bootstrap something, avoiding mobile specific page is better