如何管理多个(不同)视图层

发布于 2024-07-27 14:49:30 字数 393 浏览 2 评论 0原文

我有一个网站(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

水水月牙 2024-08-03 14:49:30

我可以认为有两种方法可以做到这一点

  1. 如果您的域不同,您可能必须使用 apache Web 服务器或 IIS,并且存储可以存储在服务器中的 css、徽标和其他 UI 内容。

  2. 如果您使用的是 .net(我认为是因为您正在谈论母版页并且您的域没有不同),您可以向您的 Web 应用程序添加一些逻辑,以便根据一些规则(例如用户名)从一个模板切换到另一个模板或个人资料。 如果您使用.net,我认为您可以生成不同的皮肤并根据您必须实现的某些逻辑分配它们。 如果您使用某种不同的语言,您还可以生成一个模板并根据您的规则进行切换。

希望这可以帮助。

I can think in two way of doing this

  1. 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.

  2. 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.

流绪微梦 2024-08-03 14:49:30

我们使用 App_GlobalResources 文件夹来执行此操作

  • App_GlobalResources\ServerFault.resx
  • App_GlobalResources\StackOverflow.resx
  • App_GlobalResources\MetaStackOverflow.resx

以及辅助类:

public static class Resources
{
public static string TeamEmail { get { return GetString("TeamEmail"); } }    
public static string GetString(string key)
{
    return HttpContext.GetGlobalResourceObject(
         GlobalApplication.CurrentSite.ToString(), key).ToString();
}
}

它出现在视图中,如下所示:

<a href="mailto:<%= Resources.TeamEmail %>">contact us</a>

对于更多总替换(例如,/faq),我们有多个常见问题解答副本,如下所示:

  • Faq-ServerFault.aspx
  • Faq-StackOverflow.aspx
  • Faq-StackOverflowMeta.aspx code>

构建会为每个服务器适当地重命名文件。

(请注意,这些是内容视图,因此它们实际上只是常见问题解答内容本身,母版页决定了布局的其余部分)

We use the App_GlobalResources folder to do this

  • App_GlobalResources\ServerFault.resx
  • App_GlobalResources\StackOverflow.resx
  • App_GlobalResources\MetaStackOverflow.resx

with a helper class:

public static class Resources
{
public static string TeamEmail { get { return GetString("TeamEmail"); } }    
public static string GetString(string key)
{
    return HttpContext.GetGlobalResourceObject(
         GlobalApplication.CurrentSite.ToString(), key).ToString();
}
}

and it appears in the view like so:

<a href="mailto:<%= Resources.TeamEmail %>">contact us</a>

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)

不奢求什么 2024-08-03 14:49:30

您说您有一个网站,并且想将其扩展到另一个主题。 我认为你应该这样想:

  • 你有一个网络应用程序来完成你的工作。
  • 您有一个网站,您已经部署了该网络应用程序,
  • 现在您想要另一个具有相同功能(就像 SO-SF 一样)但外观不同的网络应用程序,
  • 我认为您的任务只是配置您的Web 应用程序看起来不同,并将其部署在单独的服务器上

注意:
* 这两个网站将相互独立。 他们不会有共同的数据!
* 如果您希望网站能够交互,最好让 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:

  • you have a web app that does your job.
  • you have a website on which you've deployed that web app
  • now you want another webapp with the same functionality (just like SO-SF), but different look and feel
  • I think your task is just configuring your web app to look different, and deploying it on a separate server

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文