在 ASP.NET 中创建一个适用于 Blackberry、Windows Mobile 和 iPhone 的迷你站点 [英] Creating a mini-site in ASP.NET that works on Blackberry, Windows Mobile, and iPhone

查看:11
本文介绍了在 ASP.NET 中创建一个适用于 Blackberry、Windows Mobile 和 iPhone 的迷你站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个面向桌面浏览器的 ASP.NET 网站.我们想要启用一个可选的移动视图(例如 http://m.sample.com),它将提供一个几个简单的页面,主要是文本.不需要 AJAX 甚至 Javascript,也不需要用户输入 - 它实际上只是带有一些链接的文本表格,可以在页面之间导航.

I'm working on an ASP.NET website which targets desktop browsers. We want to enable an optional mobile view (e.g. http://m.sample.com) which will offer a few simple pages which will be mostly text. There will be not need for AJAX or even Javascript, and there's no user input - it's really just tables of text with a few links to navigate between the pages.

设置它以使其适用于 Blackberry、Windows Mobile 和 iPhone 的最佳方法是什么?

What's the best way to set this up so it will work on Blackberry, Windows Mobile, and iPhone?

我应该查看ASP.NET Mobile 支持,还是只是滚动我自己的页面?

Should I be looking at ASP.NET Mobile support, or just rolling my own pages?

更新:这是针对 m.microsoftpdc.com.我们采用了/Mobile 子文件夹方法,并使用了 Scott Hanselman 的 iPhone 视口提示和其他内容.

UPDATE: This was for m.microsoftpdc.com. We went with the /Mobile subfolder approach, and used Scott Hanselman's iPhone tips for viewport and other stuff.

推荐答案

我过去曾这样做过,我这样做的方式是通过为桌面创建一个目录并为移动创建一个目录来分隔页面.这使您可以更好地分离视图,因为实际上它们有很大不同.在 ASP.NET 表单中,我经常使用 Model View Presenter 模式因为它符合 ASP.NET Forms 的最佳运行方式.这样我就可以在两个视图之间重用一些代码.然后在站点的 index.aspx 页面中,您只需解析请求的用户代理字符串以找出浏览器并相应地重定向.因此,例如一个拥有 iphone 的人访问您的网站,您解析 用户代理字符串 并确定它是一部 iphone.然后重定向到指向 Mobile/Index.aspx 页面的 m.sample.com.否则,您将重定向到 Desktop/Index.aspx.

I have done this in the past and the way I did it is by separating the pages by creating a directory for Desktop and creating a directory for Mobile. This gives you better separation of the views, since in reality they are a lot different. In ASP.NET Forms I used the Model View Presenter pattern a lot since it went with the way ASP.NET Forms functioned the best. That way I could reuse some code between the two views. Then in your index.aspx page for the site, you just parse the user-agent string of the request to figure out the browser and redirect accordingly. So, for example a person with an iphone comes to your site, you parse the user-agent string and figure out it is an iphone. Then you redirect to m.sample.com which is pointing to Mobile/Index.aspx page. Otherwise you redirect to Desktop/Index.aspx.

我在页面级别做了用户代理字符串的解析,当然你也可以在 HttpModule 或 HttpHandler 级别做这种逻辑.

I did the parsing of the user-agent string at the page level, but of course you could do this kind of logic in the HttpModule or HttpHandler level also.

我只是推出了自己的页面,因为我们没有针对支持 WML 的手机.在我看来,这将是使用 ASP.NET Mobile 支持的唯一原因,就是如果您还想支持支持 WML 的手机.

I just rolled my own pages since we weren't targeting phones that have WML support. That would be the only reason in my opinion to use the ASP.NET Mobile support, is if you want to support WML enabled phones also.

这篇关于在 ASP.NET 中创建一个适用于 Blackberry、Windows Mobile 和 iPhone 的迷你站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆