用于移动设备的 Web - ASP.NET 的最佳实践 [英] Web for mobile devices - best practices for ASP.NET

查看:15
本文介绍了用于移动设备的 Web - ASP.NET 的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

开始为移动设备(任何手机)构建网络应用程序.
使用 ASP.NET 3.5/ASP.NET 4.0 和 C# 的最佳方法是什么?

Starting to build web applications for mobile devices (any phone).
What would be the best approach using ASP.NET 3.5/ASP.NET 4.0 and C#?

更新(2010 年 2 月)
有使用 windows mobile 7 的消息吗?

UPDATE (feb2010)
Any news using windows mobile 7?

推荐答案

这取决于你是真的想要支持每部手机还是只支持高端或 iPhone 等没有的新手机呈现网页的许多限制.如果您可以根据要求在手机上要求真正的HTML 渲染、Javascript 和 cookie 支持,那么真正的限制是屏幕的有限尺寸.您应该在 ASP.NET 中进行正常"的 Web 开发,注意页面的大小.

It depends if you really want to support every cell phone or only high end or new phone like the iPhone which don't have many limitations rendering web pages. If you could ask for real HTML rendering, Javascript and cookies support on the phone as requirement, then the real constraint is the limited size of the screen. You should do fine with "normal" web development in ASP.NET taking care to the the size of the pages.

如果是这样,你可以在这里停止阅读.

如果您真的想支持所有手机,尤其是旧手机,您应该知道有不同类型的手机.其中许多具有限制和约束显示网页.其中一些可以使用 JavaScript,但很多都不能.其中一些可以显示 HTML 内容,但其他许多则不能.他们必须依靠无线标记语言"标准来访问网络.因此,构建一个支持所有这些不同设备的网站并不容易.

If you really want to support every cell phone, especially old ones, you should be aware that there are different types of phones. Many of them have limitations and constraints showing web pages. Some of them can use JavaScript, but many of them do not. Some of them can display HTML content, but many others can not. They have to rely on the "Wireless Markup Language" standard for accessing web. So, it's not easy to build a website that supports all of these different devices.

这里有一些指向一般内容的链接(不是特定于 ASP.NET 的),它们可以帮助了解全貌:

Here are some links to general content (not ASP.NET specific), which could help getting the whole picture:

然而,正如我已经提到的,它们的主要限制是比普通 PC 上的屏幕小.而且很多手机不支持JavaScript、Cookies,有的甚至不显示图片.

Their main limitation however is, as I already mentioned, the smaller screen than on normal PC's. And many cell phones do not support JavaScript, Cookies and some even don't show images.

手机有特殊的标记标准.例如,WML 页面 是一种广泛采用的手机标准.WML 代表基于 XML 的无线标记语言".您可以在 此处在 w3schools.com 上找到 WML 的描述和参考.

There are special markup standards for cell phones. WML pages is for example a widely adopted standard for cellphones. WML stands for "Wireless Markup Language" which is based on XML. You can find a description and reference of WML here on w3schools.com.

下面的代码显示了一个示例 WML 页面:

The code below shows a sample WML page:

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
   "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>
   <card id="card1" title="Stackoverflow">
      <do type="accept" label="Menu">
         <go href="#card2"/>
      </do>
      <p>
         <select name="name"> 
            <option value="Questions">Questions</option>
            <option value="MyAccount">My account</option>
            <option value="FAQ">FAQ</option>
         </select>
      </p>
   </card>
   <card id="card2" title="Menu">
      <p>
           You selected: $(name)
      </p>
   </card>
</wml>

好消息是,ASP.NET 会自动呈现 WML(和其他移动标记标准)内容.您不必自己编写 WML 文件.内置机制检测 Web 请求的设备类型(手机).但是,ASP.NET 上的移动设备检测对于某些(较新的)设备无法正常工作.查看 WURFL,这是一个 XML 配置文件,其中包含有关许多移动设备的功能和特性的信息.

The good news is, that ASP.NET renders WML (and other mobile markup standards) content automatically. You don't have to write WML files yourself. A built-in mechanism detects the type of device (cell phone) of the web requests. However, mobile device detection on ASP.NET does not work correctly for some (newer) devices. Take a look at WURFL, an XML configuration file which contains information about capabilities and features of many mobile devices.

您可以在标准 Web 浏览器中测试您在 ASP.NET 中开发的页面,但它不会给出您开发的内容的正确画面.有一些模拟器可用于解决此问题,它们在您的台式计算机上模拟手机.有一篇 Microsoft 支持文章 其中解释了您可以在哪里下载它们.

You can test the pages you develop in ASP.NET in a standard web browser, but it would not give th right picture of what you have developed. There are some emulators available for this problem, which simulate a cell phone on your desktop computer. There is a Microsoft support article which explains where you can download them.

ASP.NET 移动控件(以前称为Microsoft 移动 Internet 工具包")扩展了 .NET 框架和 Visual Studio,通过使 ASP.NET 能够向各种移动设备提供标记来构建移动 Web 应用程序.

The ASP.NET Mobile Controls, formerly knowns as the "Microsoft Mobile Internet Toolkit" extend the .NET Framework and Visual Studio to build mobile Web applications by enabling ASP.NET to deliver markup to a wide variety of mobile devices.

ASP.NET 移动控件呈现适当的标记(HTML 3.2、WML 1.1、cHTML、XHTML),同时处理不同的屏幕尺寸、方向和设备功能.

The ASP.NET mobile controls render the appropriate markup (HTML 3.2, WML 1.1, cHTML, XHTML) while dealing with different screen sizes, orientations and device capabilities.

在官方网站上此处了解更多信息.

这篇关于用于移动设备的 Web - ASP.NET 的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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