[英]Visual Studio solution “design” for multiple projects
I'm currently building a MVC 4 mobile site in jQuery Mobile, to compliment the regular desktop version (built in MVC 3). 我目前正在jQuery Mobile中建立一个MVC 4移动网站,以补充常规的桌面版本(内置于MVC 3中)。
I have added a project to my solution for the mobile site (so I have two projects). 我已经为移动网站的解决方案添加了一个项目(因此,我有两个项目)。
Since I can re-use most models I just get them from the original project by including those models in my new mobile project. 由于我可以重复使用大多数模型,因此只要将这些模型包含在新的移动项目中,便可以从原始项目中获得它们。
I'm pretty fresh with .NET MVC so I need your guidence about best practices when it comes to multiple projects and what problems I might run into when deploying. 我对.NET MVC非常了解,所以我需要您指导有关多个项目的最佳实践以及部署时可能遇到的问题。
Im planning to deploy this mobile site either under a sub-domain (eg mobile.domain.com) or just as domain.com/mobile. 我打算将该移动站点部署在子域(例如mobile.domain.com)下,也可以作为domain.com/mobile进行部署。
Will the mobile project still be able to access the models after it's deployed? 部署后,移动项目是否仍然可以访问模型?
Do you somehow deploy the whole solution? 您是否以某种方式部署了整个解决方案? And in that case, how do you decide that the mobile project should reside in a specific subdomain or folder?
在这种情况下,您如何确定移动项目应驻留在特定的子域或文件夹中?
Is it a smart idea to just reference the models/classes from the original project, or will this somehow make it less flexible? 仅引用原始项目中的模型/类是一个聪明的主意,还是会以某种方式使其不那么灵活? I guess the other way is to copy the models to the mobile projects "Models" folder?
我猜另一种方法是将模型复制到移动项目的“模型”文件夹中?
How would you go about this? 您将如何处理?
Best regards Mikael 此致Mikael
One web project shouldn't be referencing the other. 一个Web项目不应引用另一个Web项目。 It is okay to move your models to another library that both web projects reference.
可以将模型移到两个Web项目都引用的库中。 You shouldn't need to copy your code.
您不需要复制代码。
I assume you need a separate project because you don't want to reuse your actions. 我假设您需要一个单独的项目,因为您不想重复使用操作。 There's no law that says you can't return a different view based on how the user uses your site.
没有法律说您不能根据用户使用您的网站的方式返回不同的视图。 Just pass a different path to the
View()
method. 只需将其他路径传递给
View()
方法。 This way you aren't duplicating all the controller logic, authentication logic, etc. 这样,您就不会复制所有控制器逻辑,身份验证逻辑等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.