一、App_Data :存放数据库或xml文件。
二、App_Start: 配置文件夹,
1、BundleConfig.cs (打包器,打包专用的配置文件)
2、FilterConfig.cs(过滤器配置)
书写过滤规则 如异常过滤,权限过滤等
3、RouteConfig.cs (路由配置)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace HPIT.RentHouse.Admin
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id =
UrlParameter.Optional }
//controller = "Home", action = "Index",配置为默认打开【views】中【home】文件夹中的【index.cshtml】首页文件.
);
}
}
}
三、Content(放CSS样式文件或图片)
主要存放 CSS文件。
四、Controllers(放控制器文件,MVC中的C)
1、存放与Views中cshtml文件对应.cs代码文件。
2、在Controllers右键,添加控制器后(如:userControllers,注意,起名后面一定要带Controllers),系统会自动在Views中添加一个user的文件夹。
3、在Index点右键可以【添加视图】,添加后,在Views中增加一个index.cshtml文件。
五、fonts(图标字体文件)
主要存放字体文件。
六、Models(放ViewsModels,MVC中的M)
存放实体对象,数据结构
七、Scripts(存放js和JQ等脚本文件)
八、views(存放前台html页面的文件夹,,MVC中的V)
1、shared(存放共享母板页文件夹)
2、_Layout.cshtml(系统默认通用母板文件)
一般用于存放所有视图页面公用的js、css等载入,这样,就不需要在每个cshtml页面重复载入了。
九、Web.config(配置文件,包括:数据库连接字符串等)
十、Global.asax:全局应用程序
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
namespace HPIT.RentHouse.Admin
{
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
//此处顺序不能改
AreaRegistration.RegisterAllAreas();
//
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
//过滤器
RouteConfig.RegisterRoutes(RouteTable.Routes);
//路由
BundleConfig.RegisterBundles(BundleTable.Bundles);
//打包器
}
}
}
总结图