1、新建一个项目TestAdmin项目类型随便选一个,待会删掉,因为这里我只需要解决方案名称  【项目存放于F盘    F:\TestAdmin

2、新建一个 ZGJ.Web 的前台MVC项目,将开始的那个随便选的项目删掉  【ZGJ.Web地址  F:\TestAdmin\ZGJ.Web

3、新建一个ZGJAdmin 的后台MVC项目,放在 ZGJ.Web 里面 【ZGJAdmin地址 F:\TestAdmin\ZGJ.Web\ZGJAdmin

4、为了美观  将项目 ZGJAdmin  重命名为 ZGJ.Admin 并且在其属性中将程序集名称及默认命名空间名称一起改成 ZGJ.Admin

注意:不要删除 ZGJ.Admin 下的 web.config ,否则添加Controller是会出错   运行所选代码生成器时出错 参数错误 HRESULT: 0x80070057 (E_INVALIDARG)

5、在 ZGJ.Web 下新建一个视图引擎  CustomerRazorViewEngine  继承自 RazorViewEngine

   public class CustomerRazorViewEngine : RazorViewEngine
{
public CustomerRazorViewEngine()
{
AreaViewLocationFormats = new[]
{
//default
"~/ZGJAdmin/Views/{1}/{0}.cshtml",
"~/ZGJAdmin/Views/Shared/{0}.cshtml"
};
AreaMasterLocationFormats = new[]
{
//default
"~/ZGJAdmin/Views/{1}/{0}.cshtml",
"~/ZGJAdmin/Views/Shared/{0}.cshtml"
};
ViewLocationFormats = new[]
{
//default
"~/Views/{1}/{0}.cshtml",
"~/Views/Shared/{0}.cshtml"
};
MasterLocationFormats = new[]
{
//default
"~/Views/{1}/{0}.cshtml",
"~/Views/Shared/{0}.cshtml"
};
AreaPartialViewLocationFormats = AreaViewLocationFormats;
PartialViewLocationFormats = ViewLocationFormats;
}
}

6、在 ZGJ.Web 的 Global.asax 中使网站启动时加载视图引擎

    public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new CustomerRazorViewEngine());
}
}

7、修改  ZGJ.Web  中的 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 },
namespaces: new[] { "ZGJ.Web.Controllers" }
);
}

8、注册区域 在 ZGJ.Admin 中添加类 AdminAreaRegistration  继承自 AreaRegistration

    public class AdminAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Admin";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Admin_default",
"Admin/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", area = "Admin", id = "" },
new[] { "ZGJ.Admin.Controllers" }
);
}
}

9、在 ZGJ.Admin 的 View 目录下 添加 _ViewStart.cshtml 布局文件

@{
Layout = "~/ZGJAdmin/Views/Shared/_Layout.cshtml";
}

10、在 ZGJ.Admin 的 View 目录下添加 Shared 目录 并添加_Layout.cshtml 布局文件

11、在 ZGJ.Admin 的属性中修改项目的输出目录

 发布

1、在ZGJ.Web 中 打包/发布Web 配置 Release 并选中此项目文件夹中的所有文件

2、编辑解决方案文件  ZGJ.Web..csproj 在最后面添加

  <Target Name="ExcludeRootBinariesDeployment">
<ItemGroup>
<RootBinFiles Include="bin\*">
<InProject>false</InProject>
</RootBinFiles>
</ItemGroup>
<PropertyGroup>
<ExcludeFilesFromDeployment>
**\*.Debug.config;
**\*.Release.config;
**\obj\**;
**\bin\*.xml;
**\*.cs;
**\packages.config;
**\*.csproj;
**\*.csproj.user;
ZGJAdmin\bin\**;
ZGJAdmin\db_backups\*.bak;
Properties\**\*;
</ExcludeFilesFromDeployment>
</PropertyGroup>
</Target>
<Target Name="ExcludeRootBinariesPackage" DependsOnTargets="ExcludeRootBinariesDeployment" BeforeTargets="ExcludeFilesFromPackage">
<ItemGroup>
<ExcludeFromPackageFiles Include="$(ExcludeFilesFromDeployment)" />
</ItemGroup>
</Target>

最新文章

  1. Coursera系列-R Programming-Final Week-Assignment3 &amp; 总结
  2. static成员变量与返回对象的引用
  3. CentOS下MySQL忘记root密码解决方法【转载】
  4. 利用SOLR搭建企业搜索平台 之——solr的查询语法
  5. java 环境变量设置
  6. 【mongoDB中级篇②】索引与expain
  7. 我的c语言经历
  8. Verilog HDL常用的行为仿真描述语句
  9. Oracle执行计划——all_rows和first_rows(n) 优化器模式
  10. Eclipse 每次打开workspace目录记录位置?
  11. Android艺术——探究Handler运行机制
  12. ipset 教程
  13. 10. Condition 控制线程通信
  14. docker 安装mysql示例
  15. 【亲测】502 Bad Gateway 怎么解决?
  16. [luogu1912][bzoj4196][NOI2015]软件管理器
  17. 在系统中使用Bean Validation验证参数
  18. linux 添加本地yum源
  19. JDK7与JDK8中HashMap的实现
  20. linux 删除指定日期之前的文件

热门文章

  1. jQuery获取动态生成的元素
  2. jQuery Validation让验证变得如此容易(三)
  3. CodeBlocks的下载安装、配置、简单编程
  4. SVN Access to &#39;/svn/Test/!svn/me&#39; forbidden,不能更新解决办法
  5. VC中如何设置菜单项的触发状态?
  6. .net下灰度模式图像
  7. enode框架step by step之框架要实现的目标的分析思路剖析1
  8. MFC注册表操作
  9. C语言之函数的声明
  10. sublime text3 3103 激活码