I've just followed Scott Hanselmans tutorial on making a switchable site in MVC4.
I'm using the Opera mobile emulator to test as I don't have VS2102.
When rendering my page in the emulator Request.Browser.IsMobileDevice
is false although it still renders the mobile view.
My questions are:
Request.Browser.IsMobileDevice
.Edit:
I think I realised my mistake:
To get it to work with the opera emulator I added a MobileDisplayMode
as described here:
ASP.NET MVC 4 Mobile Features
It seems that that solution works with rendering correctly but Request.Browser.IsMobileDevice
won't work. The same goes for ViewContext.HttpContext.GetOverriddenBrowser().IsMobileDevice
is there a way to get around this?
ASP.NET MVC 4 is a framework for building scalable, standards-based web applications using well-established design patterns and the power of the ASP.NET and the . NET framework. This new, fourth version of the framework focuses on making mobile web application development easier.
To do this, right click on your mvc project, choose Properties , then select the Web tab and then in the right pane, select Specific Page and enter the url say " Home/Index ".
MVC recognize Mobile device by matching the HTTP request header with browser config files present in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\Browsers
The asp.net MVC browser detection approach is not great so i recommend using some sort of DDR
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With