格式ASP.Net MVC应用程序的桌面和移动浏览器

问题描述:

我工作的一个ASP.Net MVC应用程序与我希望能够为桌面浏览器和移动浏览器进行格式化的意见。这两种格式都将使用相同​​的控制器和动作,但需要不同的看法。

I am working on an ASP.Net MVC application that with views that I want to be able to format for desktop browsers as well as mobile browsers. Both formats would use the same Controllers and Actions but require different views.

什么是做到这一点的最好方法是什么?办一个浏览器在操作检测,然后调用相应的看法?是否认为做浏览器检测,然后使自己相应的?有之间的一些回报查看(); 并在观点实际上被处理,我可以重写?

What's the best way to do this? Do I do a browser detect in the Action and then invoke the appropriate view? Does the view do the browser detect and then render itself accordingly? Is there something in between return View(); and when the view actually is processed that I can override?

感谢

ScottHa有这篇文章关于解决了同样的问题,针对与ASP.NET MVC多个设备。

ScottHa has this post about targeting multiple devices with ASP.NET MVC addressing that same problem.

我会建议无论是在视图或控制器和视图之间的事情(在视图引擎...)

I would suggest either in the view or in something between the controller and the view (the ViewEngine...)