简体   繁体   English

适用于移动和常规Web浏览器的ASP.net

[英]ASP.net for mobile and regular web browsers

I am designing ASP.net Web pages and not sure if this would be the right way to do this. 我正在设计ASP.net网页,但不确定这样做是否正确。 I am designing the web sites that will be accessed from either regular computers or mobile devices (phone). 我正在设计可从常规计算机或移动设备(电话)访问的网站。 I was thinking to detect at very first page that whether users are coming from mobile browser or regular browser and direct to appropriate pages. 我当时想在第一页检测用户是来自移动浏览器还是来自常规浏览器并定向到适当的页面。 So for mobile users, create/display separate UIs (rearrange controls to fit on mobile device) and for regular users, create/display separate UIs. 因此,对于移动用户,创建/显示单独的UI(重新排列控件以适合移动设备),对于普通用户,创建/显示单独的UI。 The backend functionalities will be same, but just the UIs. 后端功能将是相同的,只是UI。 Therefore, in this case I will create two separate projects in same solution, one for mobile UIs, and other one for regular UIs, but same code behinds. 因此,在这种情况下,我将在同一解决方案中创建两个单独的项目,一个用于移动用户界面,另一个用于常规用户界面,但后面的代码相同。 Would this be good idea? 这是个好主意吗?

Thanks for your help. 谢谢你的帮助。

In Asp.Net you're really tightly coupled to your views (aspx's). 在Asp.Net中,您确实与视图(aspx)紧密相连。 you would have a really hard time If you ever needed to split a large view into several smaller ones for the mobile devices. 如果您需要将大型视图分为几个较小的移动设备视图,则将非常困难。

I would do one of two things: 1) go with asp.net MVC which is a lot better at this than plain old asp.net (however even here it's not just smooth sailing) example here: http://davidhayden.com/blog/dave/archive/2009/07/29/aspnetmvciphone.aspx 我会做以下两件事之一:1)使用asp.net MVC,它比普通的旧asp.net更好(不过,即使在这里不仅顺风顺水),这里的示例: http : //davidhayden.com/博客/dave/archive/2009/07/29/aspnetmvciphone.aspx

2) have as much as possible of all common logic taken out from the aspx/aspx.cs/master/master.cs files (which is a good idea in any case to enable testing) and just have one directory for each of the frontend options (not reusing the actual aspx's between the two modes) 2)尽可能多地从aspx / aspx.cs / master / master.cs文件中取出所有常见逻辑(无论如何启用测试都是一个好主意),并且每个前端只有一个目录选项(不重用两种模式之间的实际aspx)

having two separate projects will probably only cause you headache for deployment, I'd say it's enough to split the modes into their own directoris within the same project. 有两个单独的项目可能只会让您为部署感到头痛,我要说的是,将模式拆分为同一项目中各自的Directoris就足够了。

Well if you create a class on the backend, then you don't have to maintain the working code in two places. 好吧,如果您在后端创建一个类,那么您不必在两个地方维护工作代码。 You can have your code behind pages reference the class to do all the heavy lifting. 您可以让页面后面的代码引用该类来完成所有繁重的工作。 You'll still need to maintain two pages the way you are setting it up, but any fixes/updates can be done just once (assuming it's not a UI change). 您仍然需要按照设置方式来维护两个页面,但是任何修复/更新都只能进行一次(假设这不是UI更改)。

I think you should look Mobile Web App toolkit . 我认为您应该看一下Mobile Web App工具箱 If you use MVC you can make 1 project. 如果使用MVC,则可以制作1个项目。 I recommend you don´t use mobile controls, they are deprecated. 我建议您不要使用移动控件,因为它们已过时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM