ASP.net MVC项目结构 [英] ASP.net MVC project structure

查看:214
本文介绍了ASP.net MVC项目结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我创建了以下项目结构为我的新asp.net mvc的项目中的任何我一些反馈,其他人是如何构建自己的项目后我是否会提高矿井...

下面是我到目前为止有:

  +资产
- +图片
- +脚本
- +样式表
- + ...更多的东西喜欢这里的上方
+控制器
- +支持
- +操作的任何自定义动作类
- +控制器'基地控制器类
+模型
- +域名包含专门查看特定域逻辑的任何类
- + UrlProcessing编码/解码的业务实体的URL部分
- + ...更多的东西喜欢这里的上方
- +视图'包含视图模型
- +支持
--- +浏览'基类的任何视图模型
+支持
- +应用全球应用接口类(包装了全球ASAX的功能,即类)
- +配置类型化配置类
- +助手',你把其他HTML辅助类等
- +服务
- 上MVC开机运行+引导的任务是具体到MVC项目
- +反'特定的IoC登记注册为这个项目
- + ...更多的东西喜欢这里的上方
+浏览
- +首页
- +共享
- + ...更多的东西喜欢这里的上方

干杯安东尼


解决方案

我得到了你们的类似的结构也有一些例外:


  

      
  1. 支持被命名为基础结构(命名空间UI组件的使用只)

  2.   
  3. 国际奥委会在不同项目(项目全球使用的基础设施的功能)。 UI仅具有程序集名称StructureMaps注册反转(IoC按照惯例初始化)。一种方法从一个codeCampServer源被盗。日志,配置部分放在这里了。

  4.   
  5. 查看/ [ControllerName]有部分子可能被更分为

      (这涉及到与杂耍的ViewEngine,以便它可以找到的意见/局部视图)。

  6.   
  7. 查看/ [ControllerName]有LocalResources文件夹(与部分子文件夹)

  8.   
  9. 没有根据控制器添加任何子文件夹(...还)。我喜欢让他们干净,很愚蠢的。

  10.   

和一些例外情况,与相关型号:


  

      
  1. 所有的业务逻辑住在域装配,Domain.Model命名空间与技术方面的基础设施层有一定的帮助。

  2.   
  3. 查看模型(我称他们的ViewData)住在UI组件ViewData的文件夹下,类似的文件夹,视图是结构化的。采摘方法从Kigg(除了我构建他们按次像SearchViewData,有时每局部视图偶数)。

  4.   

它的工作不够好,到目前为止

需要注意的是结构化的ViewData的(我甚至构建我的javascript同样的方式,查看== JS文件,其中包含在命名为[视图名]对象的一切)按次的可能不适合更复杂的网络可以接受的网站。

呵呵...和=>文件夹==命名空间我。我想这是一个很好的做法。

Hi guys I have created the following project structure for my new asp.net mvc project any I was after some feedback as how other people are structuring their projects and if I would improve mine...

Here is what I have so far:

+Assets
-+Images 
-+Scripts 
-+Stylesheets 
-+...              'More things like the above here
+Controllers 
-+Support
--+Actions         'Any custom action classes
--+Controllers     'Base controller classes
+Models
-+Domain           'Contains any class that specialise view specific domain logic
--+UrlProcessing   'Encoding/decoding business entities as URL parts 
--+...             'More things like the above here
-+Views            'Contains view models
--+Support
---+Views          'Base classes for any view models
+Support
-+Application      'Global application interface classes (i.e. class that wraps the function of the global asax)
-+Configuration    'Typed config classes
-+Helpers          'Where you put additional html helper classes, etc
-+Services
--+Bootstrap       'Tasks that run on mvc start-up that are specific to the MVC project
--+Inversion       'Specific IoC registration registrations for this project 
--+...             'More things like the above here
+Views
-+Home
-+Shared 
-+...              'More things like the above here

Cheers Anthony

解决方案

I got similar structure of yours with some exceptions:

  1. Support is named Infrastructure (namespace for UI assembly usage only)
  2. IoC is in different project (project for globally used Infrastructure functionality). UI has StructureMaps Registry only with assembly names (IoC is initialized by convention). Approach kind a stolen from CodeCampServer source. Logging, configuration sections goes here too.
  3. Views/[ControllerName] has Partial subfolder which might be even more divided
    (this involves juggling with ViewEngine so it could find views/partial views).
  4. Views/[ControllerName] has LocalResources folder (with Partial subfolder)
  5. Haven't added any subfolder under Controllers (...yet). I like to keep them clean and quite stupid.

And some more exceptions, related with Model:

  1. All business logic lives in Domain assembly, Domain.Model namespace with some help of Infrastructure layer for technical aspects.
  2. View models (i'm calling them ViewData) lives in UI assembly under ViewData folder, structured in folders similar as Views are. Picked approach from Kigg (except that i structure them per View like SearchViewData, sometimes even per partial view).

It works good enough so far

Note that structuring ViewData (i even structure my javascript the same way, View==JS file which contains everything under object named as [ViewName]) per view might not be acceptable for more complicated web sites.

Oh... and => folder==namespace for me. I guess that's a good practice.

这篇关于ASP.net MVC项目结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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