首页 新闻 会员 周边

asp.net mvc5项目中使用了areas,网页打不开

0
悬赏园豆:30 [已解决问题] 解决于 2016-04-24 19:39

在asp.net mvc 5项目中,新建了areas区域,无法访问路径localhost/member/user/register,如下图

相关设置,route.config如下图

Areas中的路径设置文件MemberAreaRegistration.cs如下图

请问哪里出错了?

RunningYY的主页 RunningYY | 初学一级 | 园豆:11
提问于:2016-04-23 16:43
< >
分享
最佳答案
0

你难道不是用工具生成,手写的么?

 

public class memberAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "member";
}
}

public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"member_default",
"member/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
}
}

 

 

用区域后,URL多了个区域名称;另外,要注意区域里controller名字不能与其他controller名称重复。

收获园豆:30
Ropean | 初学一级 |园豆:121 | 2016-04-24 19:23

是的,我的路由模式写错了,谢谢哦

RunningYY | 园豆:11 (初学一级) | 2016-04-24 19:38

@RunningYY:  不用客气。祝你顺利

Ropean | 园豆:121 (初学一级) | 2016-04-24 19:41
其他回答(2)
0

你访问Areas/user/register试试

刘宏玺 | 园豆:14020 (专家六级) | 2016-04-23 23:00

试过了,打不开

支持(0) 反对(0) RunningYY | 园豆:11 (初学一级) | 2016-04-24 16:41
0
public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "member_default",
                "member/{controller}/{action}/{id}",
                new { action = "Index", id = UrlParameter.Optional }
            );
        }

按上面改试试。

飞翔の金雕 | 园豆:364 (菜鸟二级) | 2016-04-24 11:32

加了区域后,不能这么写了

支持(0) 反对(0) RunningYY | 园豆:11 (初学一级) | 2016-04-24 16:42
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册