asp.net mvc - Set MVC for IPad devises to use regular web version, not .mobile -


i have made mobile version of mvc site (.mobile views) , it's works ok mobile, when emulating ipad it's using .mobile version.

how can tell mvc should pick regular version of web-page ipad devised , other non mobile devises?

we fixed adding following in global application_start method.

displaymodeprovider.instance.modes.insert(0, new defaultdisplaymode() {     contextcondition = (context => context.request.useragent != null && context.getoverriddenuseragent().indexof("ipad", stringcomparison.ordinalignorecase) >= 0) }); 

this tells mvc use default views rather mobile views ipad devices.

actually have list of 'excluded devices' listed in configuration file.

// each excluded device, set use default (desktop) view foreach (var excludedmobiledevice in excludeddevices) {     displaymodeprovider.instance.modes.insert(0, new defaultdisplaymode()     {         contextcondition = (context => context.request.useragent != null && context.getoverriddenuseragent().indexof(excludedmobiledevice, stringcomparison.ordinalignorecase) >= 0)     ); } 

also in our application, have requirement disable of mobile views through single configuration setting (without having remove of mobile view files). enables turn mobile views on , off required. again in application_start find , remove display mode id "mobile".

// remove built in mvc mobile view detection if required if (!mobileviewenabled) {     var mobiledisplaymodeprovider = displaymodeprovider.instance.modes.firstordefault(d => d.displaymodeid == "mobile");      if (mobiledisplaymodeprovider != null)     {         displaymodeprovider.instance.modes.remove(mobiledisplaymodeprovider);     } } 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -