简体   繁体   English

Visual Studio解决方案“设计”用于多个项目

[英]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进行部署。

  1. Will the mobile project still be able to access the models after it's deployed? 部署后,移动项目是否仍然可以访问模型?

  2. 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? 在这种情况下,您如何确定移动项目应驻留在特定的子域或文件夹中?

  3. 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? 我猜另一种方法是将模型复制到移动项目的“模型”文件夹中?

  4. How would you go about this? 您将如何处理?

Best regards Mikael 此致Mikael

  1. Yes but you get the whole desktop assembled code as well. 是的,但是您也可以获得整个桌面汇编的代码。
  2. This one is semantics, you could have it either way. 这是一种语义,无论哪种方式都可以。 What would be easier for consumers? 对消费者而言,什么更容易? Maybe having it's own subdomain so m.yoursite.com. 也许拥有它自己的子域,所以m.yoursite.com。
  3. You could break the common models into its own project that both sites reference. 您可以将通用模型分解成两个站点都引用的项目。 This would allow you to make changes that will affect both and you may be able to release them independently. 这样一来,您就可以进行更改,而这会影响到两者,并且您可以独立发布它们。

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.

相关问题 一个Visual Studio解决方案中的多个项目 - Multiple projects in one visual studio solution 如何发布具有两个依赖项项目的Visual Studio解决方案? - How to a publish visual studio solution with two dependencies projects to azure? 在Visual Studio解决方案中的跨项目的web.config中共享变量 - Share variable in web.config Across Projects in a Solution in Visual Studio 结构 map 初始化和多个 Visual Studio 项目 - Structure map Initialization and multiple Visual Studio projects 将解决方案分为多个项目 - Splitting an Solution into multiple projects 如何在 Visual Studio 2015 中的一个解决方案中跨多个 ASP.NET CORE 项目共享 appsettings.json 等配置文件? - How can I share config file like appsettings.json across multiple ASP.NET CORE projects in one solution in Visual Studio 2015? 多个Web项目,(几乎)Visual Studio中的相同布局 - Multiple web projects, (almost) same layout in Visual Studio Visual Studio 2008 Web服务器是否支持多个项目? - Does the visual studio 2008 Web Server supports multiple projects? 自定义 Visual Studio 解决方案 - Custom Visual Studio solution 我可以使用 c# 在 Visual Studio 中的同一解决方案中使用两个项目吗 - Can I use two projects in same solution in Visual Studio using c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM