如何根据屏幕和手持设备切换 _layout.cshtml? (.NET MVC3)
我正在设计一个小型网站,我希望能够在计算机和移动设备上浏览。我知道我可以使用以下方法轻松地为大多数移动设备更换 CSS:
<link rel="stylesheet" type="text/css" media="handheld" href="foo_mobile.css">
<link rel="stylesheet" type="text/css" media="screen" href="foo_screen.css">
但是,我真正想要完成的是根据浏览器类型(屏幕与手持设备 -加上 iPhone)。
我见过很多网站将移动设备重定向到 m.xyzCorp.com 等子域,但希望尽可能避免这种情况。
有没有示例代码或教程?我的 Google-foo 今天很弱。
TIA
I am designing a small website that I want to be able to browse both on a computer as well as a mobile device. I understand that I can swap out my CSS fairly easily for most mobile devices using the following:
<link rel="stylesheet" type="text/css" media="handheld" href="foo_mobile.css">
<link rel="stylesheet" type="text/css" media="screen" href="foo_screen.css">
However, what I really want to accomplish is swapping out the _layout.cshtml based on browser type (screen vs handheld - plus iPhone).
I've seen plenty of sites that redirect mobile devices to a sub-domain like m.xyzCorp.com but would like to avoid that if possible.
Is there any sample code or tutorials out there? my Google-foo is weak today.
TIA
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 _ViewStart.cshtml 有这样的东西
In _ViewStart.cshtml have something like this