Asp.net mvc 如何划分MVC应用程序
我需要为已经存在的MVC应用程序提供一个全新的界面。很多都是一样的,很多都是不同的。我已经想到了四种方法,但我真的不喜欢它们 有人能为选择一个选项提供一个好的基础吗Asp.net mvc 如何划分MVC应用程序,asp.net-mvc,code-organization,asp.net-mvc-areas,Asp.net Mvc,Code Organization,Asp.net Mvc Areas,我需要为已经存在的MVC应用程序提供一个全新的界面。很多都是一样的,很多都是不同的。我已经想到了四种方法,但我真的不喜欢它们 有人能为选择一个选项提供一个好的基础吗 两个应用程序:我们创建了一个全新的MVC应用程序、新域(或子域)、新一切。我们可能使用相同的数据访问库,但就web界面而言,它们是完全独立的 MVC区域:我们使用相同的应用程序,但创建员工区域和客户区域。我们使用某种类型的基于角色的路由来决定请求属于哪个区域 条件控制器语句:我们检查每个控制器方法内的请求,并决定返回哪些数据 局部视
我们在业务中使用一个有效的MVC 3应用程序来满足所有办公室管理需求。它包括员工时间、采购订单、客户管理和历史记录等功能。其中有大量客户信息,我们的客户希望看到这些信息,如他们的采购历史记录、他们花费的报告等。我们显然不想只向他们开放我们的系统。它有很多我们不希望他们看到的内部数据,我们也不希望他们能够修改任何内容。为什么不将解决方案拆分到不同的项目中 我喜欢使用代理模式 在我的解决方案中,我有三个项目:
- MVC(参考代理项目)
- 代理(它是一个类库,是对WCF项目的引用)
- WCF(这个项目知道数据库,我的实体框架在这里)
public abstract class Repository<T>
{
public abstract T GetById(int id);
}
public class CustomerRepository : Repository<CustomerEntity>
{
public override CustomerEntity GetById(int id)
{
return new CustomerEntity()
{
Id = id,
Name = "Customer " + id
};
}
}
public class RemoteOrderRepository : Repository<OrderEntity>
{
public override OrderEntity GetById(int id)
{
// You can access your external service here
}
}
public class CachedOrderRepository : RemoteOrderRepository
{
public override OrderEntity GetById(int id)
{
string cacheKey = "Order" + id;
var entity = MemoryCache.Default[cacheKey] as OrderEntity;
if(entity == null)
{
entity = base.GetById(id);
var cacheItem = new CacheItem(cacheKey, entity);
var policy = new CacheItemPolicy();
MemoryCache.Default.Add(cacheItem, policy);
}
return entity;
}
}