0

how to change area "Admin" to seprate project by MapRoute in asp.net mvc like picture enter image description here

i'm using code:

  namespace App.Web
    {
        public class RouteConfig
        {
            public static void RegisterRoutes(RouteCollection routes)
            {
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");    

                var route = routes.MapRoute(
                    "Admin_default",
                    "Admin/{controller}/{action}/{id}",
                    new { controller = "Home", action = "Index", area = "Admin", id = "" },
                    new[] { "app.Admin.Controllers" }
                );
                route.DataTokens["area"] = "Admin";

                routes.MapRoute(
                    name: "Default",
                    url: "{controller}/{action}/{id}",
                    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
                );

            }
        }
    }

but when enter url in browser:http://localhost:27824/admin/home/index => show app.Web.Controllers->home->index !! (app.Admin.Controllers->Home->index does not show !!)

enter image description here

Mehradi
  • 32
  • 7

1 Answers1

0

You can't route to a different project. Routes are project specific.

Chris Pratt
  • 232,153
  • 36
  • 385
  • 444
  • How dose nopcommerce done that?(https://nopcommerce.codeplex.com/SourceControl/latest) – Mehradi Jul 11 '15 at 08:23
  • Not sure what you're talking about specifically, but they aren't routing between projects. It's possible to merely retrieve the routing config from another project if you're just trying to get a URL, but it's non-trivial. You have to use reflection to load in the assembly for the other project and use that to create a UrlHelper, but you can only even get relative URLs with that. If the project is on another domain or in a virtual directory or something, there's no way to know that from a different project. – Chris Pratt Jul 11 '15 at 13:18