MVC4:禁用某些控制器上的移动视图

时间:2022-06-04 21:13:47

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.

我的所有视图都有.cshtml和.Mobile.cshtml。有没有办法在某些控制器上禁用.Mobile.cshtml?对于这样的控制器,我总是希望使用普通视图而不是移动视图。

Thanks!!

1 个解决方案

#1


3  

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

要强制浏览器在移动设备上加载桌面视图,您需要使用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

试试这个链接获取更多帮助http://blog.mirajavora.com/overriding-browser-capabilities-in-asp.net

#1


3  

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

要强制浏览器在移动设备上加载桌面视图,您需要使用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

试试这个链接获取更多帮助http://blog.mirajavora.com/overriding-browser-capabilities-in-asp.net