如何管理多个(不同)视图层
我有一个网站(ASP.NET MVC),我想将其扩展到另一个类似的主题(例如 stackoverflow-serverfault-superuser)。
两个网站的数据库层和控制器层是相同的。 不同之处只是视图层,并且只有一些细节:徽标、母版页和一些资源文件(部分)和 CSS。
处理这种情况的最佳方法是什么? 杰夫和他的团队是如何实现这一目标的?
我的理想目标是拥有一个解决方案(Visual Studio 解决方案)、一个包含控制器和模型的项目以及 n 个不同的项目:每个项目对应每个视图。 (添加此行以澄清)
我只需对两个解决方案(使用 SVN 或 Mercurial)进行分支,然后在发布时合并即可完成此操作?
多谢你们!
I have a website (ASP.NET MVC) which I would like to extend to another similar topic (like stackoverflow-serverfault-superuser).
Database layer and controllers layer are the same for both websites. What differs is just the view layers, and only for just a few detail: logos, masterpage and some resources files (in part) and CSS.
What's the best way to manage this situation? How is this accomplished by Jeff and his team?
My ideal goal is to have a single solution (Visual Studio solution), a project with controllers and model, and n different projects: each for every view. (added this line to clarify)
I get this done simply branching the two solutions (with SVN or Mercurial) and then merging while publishing?
Thanks guys!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我可以认为有两种方法可以做到这一点
如果您的域不同,您可能必须使用 apache Web 服务器或 IIS,并且存储可以存储在服务器中的 css、徽标和其他 UI 内容。
如果您使用的是 .net(我认为是因为您正在谈论母版页并且您的域没有不同),您可以向您的 Web 应用程序添加一些逻辑,以便根据一些规则(例如用户名)从一个模板切换到另一个模板或个人资料。 如果您使用.net,我认为您可以生成不同的皮肤并根据您必须实现的某些逻辑分配它们。 如果您使用某种不同的语言,您还可以生成一个模板并根据您的规则进行切换。
希望这可以帮助。
I can think in two way of doing this
you could have to apache web servers or IIS in case your domains are different and the store the css, logos and other UI stuff that could be store in the server.
If you're using .net which I suppouse cause you're talking about master page and your domains are not different, you could add some logic to your web app to switch from one template to another according some rules like the username or profile. If you're using .net I think you can generate to different skins and assign them according certain logic that you must implement. If you're using some different language you could also generate a template and switch it according your rules.
Hope this helps.
我们使用
App_GlobalResources
文件夹来执行此操作以及辅助类:
它出现在视图中,如下所示:
对于更多总替换(例如,/faq),我们有多个常见问题解答副本,如下所示:
Faq-ServerFault.aspx
Faq-StackOverflow.aspx
Faq-StackOverflowMeta.aspx
code>构建会为每个服务器适当地重命名文件。
(请注意,这些是内容视图,因此它们实际上只是常见问题解答内容本身,母版页决定了布局的其余部分)
We use the
App_GlobalResources
folder to do thiswith a helper class:
and it appears in the view like so:
For more total replacements (e.g., the /faq), we have multiple copies of the faq like so:
Faq-ServerFault.aspx
Faq-StackOverflow.aspx
Faq-StackOverflowMeta.aspx
The build renames the file appropriately for each server.
(Note that these are content views, so they are literally just the faq CONTENT itself, the master page determines the rest of the layout)
您说您有一个网站,并且想将其扩展到另一个主题。 我认为你应该这样想:
注意:
* 这两个网站将相互独立。 他们不会有共同的数据!
* 如果您希望网站能够交互,最好让 Web 应用程序能够与自身的其他实例交互,然后重新部署。
我希望我正确理解了您的问题,并且我所写的内容会对您有所帮助。
干杯,jrh
You say that you have a website, and you want to extend it for another topic. I think you should think is this fashion:
Notes:
* These two websites will be independent of each other. They will not have data in common!
* If you want the websites to interact, its better to make the web app capable of interacting with other instances of itself, and then redeploying.
I hope I understood what you were asking correctly, and that what I've written will be helpful.
Cheers, jrh