I built a base controller that all my controllers inherit from, and I have it configured so that it checks the browser type and immediately returns the corresponding MasterPageFile.
I am wondering if this is an effective way to do this, or if I have to optimize it differently.
Public Class BaseController : Inherits System.Web.Mvc.Controller
Protected Overrides Function View(ByVal viewName As String, ByVal masterName As String, ByVal model As Object) As System.Web.Mvc.ViewResult
If Request.Browser.IsMobileDevice Then
Return MyBase.View(viewName, "Mobile", model)
Else
Return MyBase.View(viewName, "Site", model)
End If
End Function
End Class
Also, if anyone is interested, I use the information found here to improve my checks Request.Browser.IsMobileDevice.
The file .browserI use can be found here .
source
share