【MVC】 文件及URL 的整理
我们平时在做Asp.Net MVC(以下就简称mvc)项目的时候,页面文件结构都用了“/Views/Controllers/page.aspx”,而把一些PartialView呢放在/Views/Shared 目录下面,但如果PartialView越来越多了呢。。。。如果其中还混杂着几个MasterPage,几个Error.aspx。。。。这个目录看起来就。。。。。
![]()
O my lady gaga!忒难看了,如果多了以后那更难看了。。。。。
为了看起来好看点,我准备分目录存放,我的目标是:
![]()
打开Home\Index.asp文件,放一个Login的PartialView吧。先运行一下看看吧。。。一定肯定以及确定不能运行,因为我们的mvc根本没有找到所需的文件,错误信息“The partial view 'xxx' was not found”。
我们知道mvc在查找文件的时候,会到2个目录下查找,一个是Controller目录,一个就是Shared目录,寻找Action.aspx或者Action.ascx,我们看下源代码(我下载的是asp.net mvc rc2),通过查看源代码,得知查找View或者PartialView都是通过IViewEngine.FindView和IViewEngine.FindPartialView来查找的。通过静态类:ViewEngines中的Engines,递归寻找,如果找到就显示,如果没有找到就报异常了。
ViewEngines.Engines.Add(new WebFormViewEngine
{ViewLocationFormats = new string[]
{"~/Views/Shared/Error/{0}.aspx"},
PartialViewLocationFormats = new string[]
{"~/Views/Shared/Partial/{0}.ascx"},
MasterLocationFormats = new string[]
{"~/Views/Shared/Master/{0}.Master"},
AreaMasterLocationFormats = new string[]
{"~/Areas/{1}/Share/Master/{0}.Master"}
});
.src_container{background-color:#e7e5dc; width:99%; overflow:hidden; margin:12px 0 12px 0 !important; padding:0px 3px 3px 0px}
.src_container .titlebar{ background-color:#d4dfff; border:1px solid #4f81bd; border-bottom:0; padding:3px 24px; margin:0; width:auto; line-height:120%; overflow:hidden; text-align:left; font-size:12px}
.src_container .toolbar{ display:inline; font-weight:normal; font-size:100%; float:right; cursor:hand; color:#00f; text-align:left; overflow:hidden}
.toolbar span.button{ display:inline; font-weight:normal; font-size:100%; cursor:hand; color:#00f; text-align:left; overflow:hidden; cursor:pointer;}
.src_container div.clientarea{ background-color:white; border:1px solid #4f81bd; margin:0; width:auto !important; width:100%; height:auto; overflow:auto; text-align:left; font-size:12px; font-family: "Courier New","Consolas","Fixedsys",courier,monospace,serif}
.src_container ol.mainarea{ padding:0 0 0 52px; margin:0; background-color:#f7f7ff !important}
.number_show{ padding-left:52px !important; list-style:decimal outside !important}
.number_show li{ list-style:decimal outside !important; border-left:1px dotted #4f81bd}
.number_hide{ padding-left:0px !important; list-style-type:none !important}
.number_hide li{ list-style-type:none !important; border-left:0px}
ol.mainarea li{ display:list-item !important; font-size:12px !important; margin:0 !important; line-height:18px !important; padding:0 0 0 0px !important; background-color:#f7f7ff !important; color:#4f81bd}
ol.mainarea li pre{color:black; line-height:18px; padding:0 0 0 12px !important; margin:0em; background-color:#fff !important}
.linewrap ol.mainarea li pre{white-space:pre-wrap; white-space:-moz-pre-wrapwhite-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word}
ol.mainarea li pre.alt{ background-color:#f7f7ff !important}

【MVC】 文件及URL 的整理的更多相关文章
- [ThinkPHP]MVC模块和URL访问
## ThinkPHP 3 MVC模式和URL访问#讲师:赵桐正微博:http://weibo.com/zhaotongzheng 本节课大纲: 一.什么是MVC // ...
- MVC文件上传-使用jQuery.FileUpload和Backload组件实现文件上传
本篇使用客户端jQuery-File-Upload插件和服务端Badkload组件实现多文件异步上传.MVC文件上传相关兄弟篇: 处理文件上传的服务端组件Backload 用于处理文件上传的服务端组件 ...
- ASP.NET MVC 文件上传和路径处理
ASP.NET MVC 文件上传和路径处理总结 目录 文件的上传和路径处理必须解决下面列出的实际问题: 1.重复文件处理 2.单独文件上传 3.编辑器中文件上传 4.处理文章中的图片路径 5.处理上传 ...
- 【ASP.NET MVC 牛刀小试】 URL Route
例子引入 先看看如下例子,你能完全明白吗? using System; using System.Collections.Generic; using System.Linq; using Syste ...
- HTML5 本地文件操作之FileSystemAPI整理(二)
一.文件目录操作 1.DirectoryEntry对象 属性: 1.isFile: 操作对象的是否为文件,DirectoryEntry对象固定其值为false 2.isDirectory: 操作对象是 ...
- MVC文件图片ajax上传轻量级解决方案,使用客户端JSAjaxFileUploader插件01-单文件上传
前段时间做了几个关于图片.文件上传的Demo,使用客户端Query-File-Upload插件和服务端Badkload组件实现多文件异步上传,比如"MVC文件上传04-使用客户端jQuery ...
- MVC文件上传09-使用客户端jQuery-File-Upload插件和服务端Backload组件让每个用户有专属文件夹,并在其中创建分类子文件夹
为用户创建专属上传文件夹后,如果想在其中再创建分类子文件夹,该怎么做?可以在提交文件的视图中再添加一个隐藏域,并设置 name="uploadContext". 相关兄弟篇: MV ...
- MVC文件上传08-使用客户端jQuery-File-Upload插件和服务端Backload组件让每个用户有专属文件夹
当需要为每个用户建立一个专属上传文件夹的时候,可以在提交文件的视图中添加一个隐藏域,并设置name="objectContext". 相关兄弟篇: MVC文件上传01-使用jque ...
- MVC文件上传07-使用客户端jQuery-File-Upload插件和服务端Backload组件裁剪上传图片
本篇通过在配置文件中设置,对上传图片修剪后保存到指定文件夹. 相关兄弟篇: MVC文件上传01-使用jquery异步上传并客户端验证类型和大小 MVC文件上传02-使用HttpPostedFileB ...
随机推荐
- 论文他引次数及ESI高被引论文查询方法
https://yunpan.cn/cS67Z9UEDvc2b 访问密码 f078
- linux中deb怎样安装
deb是Debian Linux的安装格式,跟Red Hat的rpm非常相似,最基本的安装命令是:dpkg -i file.debdpkg 是Debian Package的简写,是为Debian 专门 ...
- Xcode7--坑无法运行iOS9以下的模拟器
Unable to open liblaunch_sim.dylib. Try reinstalling Xcode or the simulator 解决办法 一.找到目标文件 /Applicati ...
- Mac 终端常用命令备忘
Tab 补全 pwd 显示路径 一 .ls ls -lh 查看当前路径详细文件 ls .. 返回上级目录 ls -a 显示隐藏文件 ls -a -l 以详细列表显示 ls ../../ ...
- [Java] File文件列表
package test.file; import java.io.File; import java.io.FilenameFilter; /** * 文件列表,文件过滤 * @author Fro ...
- [Java] java中的异常处理-续
异常处理器,它由try, catch, finally以及随后的程序块组成.finally不是必须的. catch的括号有一个参数,代表所要捕捉的异常的类型.catch会捕捉相应的类型及其衍生类.tr ...
- [ActionScript 3.0] AS3 绘制立方体
package { import flash.display.Sprite; import flash.events.Event; import flash.geom.Vector3D; import ...
- JAVA中的策略模式
现在我们有一个虚基类-鸭子(abstract Duck). 有真鸭子,野鸭子,橡皮鸭子继承了该类.虚基类有swing方法,毕竟游泳是所有的鸭子都应有的功能.还有一个虚方法display,这个方法在子类 ...
- 理论沉淀:RANSAC算法
1.解决问题: 当一组样本数据中含有(较小波动的)正常数据(inliers)和(较大波动的)异常数据(outliers)且异常数据的量还不小于正常数据的量时,用最小二乘法将难以获得期望的直线(即能拟合 ...
- poj 2406 Power Strings kmp算法
点击打开链接 Power Strings Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 27368 Accepted: ...