ASP.NET MVC Areas View 引用 外部母版视图

本文详细介绍了如何在ASP.NET MVC项目中使用Area特性,并引导读者理解如何配置Area来引用外部母版视图。通过具体步骤说明了如何调整web.config文件位置,迁移_ViewStart.cshtml文件,以及正确注册Area路由。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

 

ASP.NET MVC Area =》 Areas View 引用 外部母版视图

创建项目:MVCSite.Area

 

 创建mvc area

 

1、Areas View 引用 外部母版视图

1.1 将Areas View 下    web.config  移到Areas  下

 

 1.2 MVCSite.Area View   下  _ViewStart.cshtml  移到  admin 下

 

 

 

 

 

 

 1 using System.Web.Mvc;
 2  
 3 namespace WebApplication1.Areas.area
 4 {
 5     public class areaAreaRegistration : AreaRegistration
 6     {
 7         public override string AreaName
 8         {
 9             get
10             {
11                 return "area";
12             }
13         }
14  
15         public override void RegisterArea(AreaRegistrationContext context)
16         {
17             context.MapRoute(
18                 "area_default",
19                 "area/{controller}/{action}/{id}",
20                 new { action = "Index", id = UrlParameter.Optional },
21                 namespaces: new[] { "WebApplication1.Areas.area.Controllers" }
22             );
23         }
24     }
25 }
View Code

 

 

 END

 

转载于:https://www.cnblogs.com/DataBase-123/p/9849116.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值