ASP.NET MVC routing and areas

后端 未结 2 1517
遥遥无期
遥遥无期 2020-12-30 06:38

I am messing around with ASP.NET MVC 2 Preview 2 and am trying to figure out how routing works with areas and such. In a single project implementation of areas, I want an a

2条回答
  •  隐瞒了意图╮
    2020-12-30 06:41

    Register areas in single project

    You have to add routes.cs file to the admin area folder.

        using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    
    namespace MvcAreasSingleProject.Areas.Admin
    {
        public class Routes : AreaRegistration
        {
            public override string AreaName
            {
                get { return "admin"; }
            }
    
            public override void RegisterArea(AreaRegistrationContext context)
            {
                context.MapRoute(
                    "admin_default",
                    "admin/{controller}/{action}/{id}",
                    new { controller = "Admin", action = "Edit", id = "" }
                );
            }
        }
    }
    

提交回复
热议问题