ASP.NET MVC:每个域人性化设计 [英] ASP.NET MVC: customized design per domain

查看:128
本文介绍了ASP.NET MVC:每个域人性化设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在不同的标记或页面设计ASP.NET MVC 2项目,该项目应显示相同的域模型(不同的数据)(由URL域选择)。

I'm thinking about ASP.NET MVC 2 project which should display the same Domain Model(with different data) in different mark-up or page design(selected by url domain).

我不知道哪一个加时赛这些使用方法:

I'm not sure which one ot these to use :


  1. 设置每个独特的域名+一个默认的看法?

  2. 使用领域?

  3. 任何其他想法?

你会怎么做呢?
谢谢你。

How would you do that? Thank you.

修改

我终于用我自己的解决方案就出来了。特点:

I have finally came out with my own solution. Features:


  • .NET 4 MVC 2

  • 框架,库:NCommon,EF4,MVCContrib,AntiXSS

  • 每个域加载配置(模块)

  • 语言,本地化,主题

有很多事情要做,但我可以分享我的code,以改善它。给我发送电子邮件至skorunka@genitor.cz

There is a lot of things to do, but i can share my code to improve it. Send me an email to skorunka@genitor.cz

推荐答案

我建议通过此的由罗布阿什顿后的一系列专门


  1. http://$c$cofrob.com/archive/2009/11/01/dynamically-switching-between-master-pages-in-asp.net-mvc.aspx

  2. http://$c$cofrob.com/archive/2010/02/08/multi-tenancy-in-asp.net-mvc-views.aspx

  1. http://codeofrob.com/archive/2009/11/01/dynamically-switching-between-master-pages-in-asp.net-mvc.aspx
  2. http://codeofrob.com/archive/2010/02/08/multi-tenancy-in-asp.net-mvc-views.aspx

不过,我觉得,虽然你可能需要做的视图名称如何解决一些更重要。关键的一点,我认为在罗布的帖子指出的是,意见应得到解决,位于相反的顺序,即总是期待为当前站点定义的视图,并穿越回到根在哪里了一套完整的看法是present。

However, I think though that you may need to do some overriding of how view names are resolved. The key point I think as noted in Rob's post is that views should be resolved and located in reverse order i.e. always look for views defined for your current site and traverse back to the root where a complete set of views are present.

一套独特的每个域的观点加一个
  默认?

set of views per unique domain + one default?

是 - 铭记你可能只需要具体意见为域

Yes - bearing in mind that you may only need specific views for a domain

使用领域?

没有 - 我不建议您拆分了应用程序在这种情况下,使用领域。我假设你的意思是每个域的区域。你应该根据功能你的应用程序还分为区域,并使用相同的想法解决的意见。

No - i dont suggest splitting your app up using Areas in this case. I am assuming that you mean an area per domain. You should still split your app into Areas based on functionality and use the same idea resolving the views.

任何其他想法?

使用罗布的想法绝对是一个不错的选择。不过,我会考虑你有多少域名(网站)期待有不同的看法。我想在这里对每个网站每个区域都有不同的看法要求的情况下(不是很YAGNI)的。所以,我一个深思熟虑的计划是需要存储的意见。一个可能的目录结构的例子。

Using Rob's idea is definitely a good option. I would however take into consideration how many domains(sites) you are expecting to have different view for. I am thinking of the case (not very YAGNI) where every area for each site has different view requirements. So i a well thought plan is needed to stored the views. An example of a possible directory structure.

-- Default
   -- Area1  // Site2's views rendered from here
      --Views
      --Shared
   -- Area2  
      --Views
      --Shared
   ...
-- Site 1 // all views from Site 1 are rendered from this folder
   -- Area1  
      --Views
      --Shared
   -- Area2  
      --Views
      --Shared
-- Site 2 // only view for Area2 are rendered from here
   -- Area2  
      --Views
      --Shared

这篇关于ASP.NET MVC:每个域人性化设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆