c# – asp.net开发人员开发其现有网站的移动版本的最佳(简单和高
我希望这个问题能够自我描述.
我目前正在开发一个在数据层中使用MS SqlServer数据库的asp.net网站. 而且我在想我有什么选择来获得移动版本(最重要的是支持BlackBerry和iPhone以及希望每个移动设备!),当在黑莓上使用时,我希望能够让它在BB的背景下运行. 我在考虑使用asp.net移动控件,但projects page似乎是一个死的/未更新的框架,并不确定是否只支持Windows手机或什么! 编辑 解决方法
如果您使用
ASP.Net MVC创建应用并创建常规和移动视图.您也可以使用
jQuery Mobile来帮助处理移动视图.
This question介绍了如何根据设备类型更改视图, 如果您使用WebForms,则可以根据浏览器更改MasterPage,从而使您能够更轻松地切换到移动版本: protected void Page_PreInit(object sender,EventArgs e) { if (Request.Browser.IsMobileDevice) MasterPageFile = "~/Mobile.Master"; } 或者使用Global.asax完全重定向移动请求: void Session_Start(object sender,EventArgs e) { // Redirect mobile users to the mobile home page HttpRequest httpRequest = HttpContext.Current.Request; if (httpRequest.Browser.IsMobileDevice) { string path = httpRequest.Url.PathAndQuery; bool isOnMobilePage = path.StartsWith("/Mobile/",StringComparison.OrdinalIgnoreCase); if (!isOnMobilePage) { string redirectTo = "~/Mobile/"; // Could also add special logic to redirect from certain // recognized pages to the mobile equivalents of those // pages (where they exist). For example,// if (HttpContext.Current.Handler is UserRegistration) // redirectTo = "~/Mobile/Register.aspx"; HttpContext.Current.Response.Redirect(redirectTo); } } } 无论哪种方式阅读这篇文章:http://www.asp.net/learn/whitepapers/add-mobile-pages-to-your-aspnet-web-forms-mvc-application (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |