eadam
eadam

Reputation: 26071

MVC4: Disable mobile views on certain controllers

I have got .cshtml and .Mobile.cshtml for all of my views. Is there a way to disable .Mobile.cshtml on certain controllers? For such controllers, I always want to use the normal views instead of mobile views.

Thanks!!

Upvotes: 5

Views: 1540

Answers (1)

Colin Bacon
Colin Bacon

Reputation: 15609

Sorry for sounding stupid. But if you always want to use a normal view, just remove the mobile view from the project.

Edit

To force the browser to load the desktop view on a mobile device you will need to use the BrowserHelper SetOverriddenBrowser

Within your action method you could do something like this

HttpContext.SetOverriddenBrowser(BrowserOverride.Desktop);

Try this link for more help http://blog.mirajavora.com/overriding-browser-capabilities-in-asp.net

Upvotes: 3

Related Questions