简体   繁体   English

跨平台开发

[英]Cross-platform development

I was just about to upload my new, redesigned website when I realised "crap, it's just like every other website." 当我意识到“废话,就像其他所有网站一样”时,我正准备上传我重新设计的新网站。

Then I had an idea. 然后我有了一个主意。 And I've spent the past 2 weeks planning. 我花了两周时间进行规划。 I have but one thing left to do, and it's proving a little difficult to figure out how I can have my website for PC's, and a whole different site for an iPad (or just larger touch based computers in general) and another for Touch-based phones, and then one for regular phones with web browsing capabilities. 我还有一件事要做,而且我觉得有点难以弄清楚如何将我的网站用于PC,以及一个完全不同的网站用于iPad(或者只是更大的触摸式计算机)以及另一个用于触摸的网站 - 基于手机,然后一个用于具有网络浏览功能的普通手机。

Is this possible? 这可能吗? I want separation. 我想要分离。 I don't want a bunch of javascript files with commands for everything inside them. 我不想要一堆带有命令的javascript文件。 I want to separate each 'website' and serve it based on the platform requesting the document. 我想将每个“网站”分开,并根据请求文档的平台提供服务。 How can we achieve this? 我们怎样才能做到这一点?

If you are to recommend any libraries that may help, note that I will not use jQuery (but list jQuery anyway as others who face this problem might not mind using jQuery) 如果你推荐任何可能有帮助的库,请注意我不会使用jQuery(但是无论如何列出jQuery,因为遇到此问题的其他人可能不介意使用jQuery)

You can use Asp.net MVC and switch your views depending on the device. 您可以使用Asp.net MVC并根据设备切换视图。 This way you can reuse all your controllers and have different views for each device you want. 这样,您可以重用所有控制器,并为所需的每个设备提供不同的视图。

Scott Hanselman wrote an article a while ago about this kind of development: http://www.hanselman.com/blog/MakingASwitchableDesktopAndMobileSiteWithASPNETMVC4AndJQueryMobile.aspx Scott Hanselman不久前写了一篇关于这种发展的文章: http//www.hanselman.com/blog/MakingASwitchableDesktopAndMobileSiteWithASPNETMVC4AndJQueryMobile.aspx

I would recommend jQuery Mobile to use in mobile devices. 我建议jQuery Mobile在移动设备中使用。 I also recommend Kendo UI Mobile, it really looks amazing but the mobile version is not free.. 我也推荐Kendo UI Mobile,它真的很神奇,但移动版本不是免费的..

I also suggest to take a look at SPA (Single Page Applications). 我还建议看看SPA(单页应用程序)。 With SPA you could have a rich javascript application ready for any device. 使用SPA,您可以为任何设备准备好丰富的JavaScript应用程序。 Combining it with Asp.Net WebApi looks very promising. 将它与Asp.Net WebApi结合起来看起来非常有前途。

Jonh Papa made a course on Pluralsight that is completely worth it: http://www.johnpapa.net/building-single-page-apps-with-knockout-jquery-and-web-api-ndash-the-story-begins/ Jonh Papa在Pluralsight上开设了一门完全值得的课程: http//www.johnpapa.net/building-single-page-apps-with-knockout-jquery-and-web-api-ndash-the-story-begins /

It's all about thinking about what you really need and how much effort you can put in. 这都是关于你真正需要什么以及你可以付出多少努力的思考。

long answer short, i think what you are looking for is Request.Browser to do redirects. 很长的答案简短,我认为你正在寻找的是Request.Browser做重定向。 You can Access things like Browser.Browser or Browser.Version, i think even a IsMobileDevice is to be found there. 您可以访问Browser.Browser或Browser.Version之类的东西,我想甚至可以在那里找到IsMobileDevice。

check out: http://msdn.microsoft.com/de-de/library/system.web.httprequest.browser.aspx 退房: http//msdn.microsoft.com/de-de/library/system.web.httprequest.browser.aspx

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

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