MVC 3 - New Area - 404 error - Resource not found - have tried route debugger

后端 未结 3 1848
旧巷少年郎
旧巷少年郎 2021-02-20 10:09

I have a small MVC 3 app - bit of a demo ground. I have one area and thats been working fine.

I have just added another area expecting to just spin up the app and it wor

3条回答
  •  盖世英雄少女心
    2021-02-20 10:40

    Try to add a class PostCardAreaRegistration under PostCard Area

    using System.Web.Mvc;
    
    namespace Areas.PostCard
    {
        public class PostCardAreaRegistration: AreaRegistration 
        {
            public override string AreaName 
            {
                get 
                {
                    return "PostCard";
                }
            }
    
            public override void RegisterArea(AreaRegistrationContext context) 
            {
                context.MapRoute(
                    "PostCard_default",
                    "PostCard/{controller}/{action}/{id}",
                    new { action = "Index", id = UrlParameter.Optional }
                );
            }
        }
    }
    

提交回复
热议问题