Asp.net 5 (MVC6) Areas 分区
2024-09-04 14:06:07
1. Startup.cs 类的 Configure方法中, 加入Area路由设置代码:
//app.UseMvcWithDefaultRoute();
app.UseMvc(routes=> {
// add the new route here.
routes.MapRoute(name: "areaRoute",
template: "{area:exists}/{controller}/{action}",
defaults: new { controller = "Home", action = "Index" });
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{id?}",
defaults: new { controller = "Home", action = "Index" });
});
2. 创建Areas相关文件夹:
3. 在Area的Views目录下的_ViewStart.cshtml文件中, 指定Area的默认模板
4. 创建Area的Controller类:
[Area("Admin")]
public class HomeController: Controller
{
public IActionResult Login()
{
return View();
}
}
5. 创建_Layout.cshtml及View文件.
最新文章
- 查看Oracle执行计划
- Fragment之间传值
- aliyun阿里云Maven仓库地址——加速你的maven构建
- October 8th 2016 Week 41st Saturday
- 使用Visual Studio Code开发AngularJS应用
- python面试题大全(二)
- M面经Prepare: Positive-Negative partitioning preserving order
- .NET: WPF Data Binding
- ios第三方分享到qq、微信、人人网、微博总结
- TopCoder SRM 633div1
- sbrk and coreleft
- WinDBG调试.NET程序示例
- 【JAVAWEB学习笔记】08_MySQL&;JDBC回顾
- 搭建ElasticSearch+MongoDB检索系统
- js生成json数据
- ruby读取源代码自身的一种方法
- MIPS 指令集开源了
- Redis 安装、配置、集群
- Regular Expression
- Expo大作战(二十)--expo中的Release channels(不重要*)
热门文章
- Unity3D学习笔记——NGUI之Localization system
- python3----智能检测编码的工具
- gtest入门简介
- rest-framework框架的基本组件分析
- python3 - property的使用
- FFmpeg总结(六)AV系列结构体之AVPacket
- Qt 静态编译后的exe太大, 能够这样压缩.
- [Spring Data Repositories]学习笔记--使用现有的repository
- 使用IDEA工具整合mybatis时使用@Resource和@Autowired自动注解bean时会显示红色问题的解决办法
- String、StringBuffer与StringBuilder的区别。