Actually the easiest way is to make one version of your site programmed to standards, and not to detect browsers: D - however, in the direct answer, to accomplish what it is in most of the ASP.NET mvc model, using:
RedirectToAction("ViewName", "ControllerName");
- a good method, but I think it is more practical if you think that you need to program different browser standards to create the main view and an alternative "mobile" view under your controller views. Then, instead of writing special code on each controller, expand the controller instead.
public class ControllerExtended : Controller { private bool IsMobile = false; private void DetectMobileDevices(){ .... } }
Then change your controller classes, instead say the ControllerExtended classes and just add one line at the beginning of each action, you have alternative views, for example:
public class ApplicationsController : ControllerExtended { // GET: /Applications/Index public ActionResult Index() { this.DetectMobileDevices(); if(this.IsMobile){ return RedirectToAction("MobileIndex"); } else { // actual action code goes here return View(); } } }
Alternatively, you can use return View ("ViewName"); but in my experience, you really want to perform different actions, and not just show the result in a different view, as in the case of the presentation of the HTML table, and not the Flex table, to help iPhone users, since the iPhone does not have flash memory, etc. (starting with this letter)
source share