ASP.NET MVC routing and areas

前提是你 提交于 2019-11-30 06:49:39

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 = "" }
            );
        }
    }
}

http://haacked.com/archive/2009/07/31/single-project-areas.aspx

routes.MapAreaRoute("Forums", 
        "admin_area", 
        "admin/{controller}/{action}/{id}", 
        new { controller = "apples", action = "search", id = "" }, 
        new string[] { "Project.Areas.Admin.Controllers" });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!