0

Problem

In asp.net mvc i have two mvc application in one solution one is website and second is admin panel. And I I have created one folder that name is administrator inside of website project and paste admin project inside of website project now I want access admin section like way :

http://localhost/website/admin

As like nopcommerce but I'm not getting how nopcommerce configured this thing in their project.

Help me out

4
  • Why don't you use Areas?! Commented Aug 3, 2015 at 17:33
  • I know about areas but I wants to create independently admin section where we can set configurations in web config in that project and any other changes we can done their easily. So do you have any other solution of my problem so please reply. Commented Aug 3, 2015 at 17:40
  • I'm pretty sure you can use area specific web.config files... Commented Aug 3, 2015 at 17:56
  • Is there anything solution except areas? Commented Aug 3, 2015 at 18:23

2 Answers 2

1

As others have stated, it may be best to use ares in order to simplify the project, but if you want to keep them separated, I think the problem you are having is updating your routing.

By default, MVC applications have the following routing config (found in the Globals.asax.cs file):

    routes.MapRoute(
        "Default",                                              // Route name
        "{controller}/{action}/{id}",                           // URL with parameters
        new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
    );

What you will need to do is look at the controller you're trying to wire up, and put in a route for that controller. For the sake of an example, I will assume your controller is called "AdminController":

    routes.MapRoute(
       name: "AdminController",
       routeTemplate: "website/admin/{action}",
       defaults: new { controller = "Admin", action = "Index"}
    );

    routes.MapRoute(
        "Default",                                              // Route name
        "{controller}/{action}/{id}",                           // URL with parameters
        new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
    );

This example shows you how to map the desired route -- http://localhost/website/admin -- to the "Index" action on the "AdminController" object.

For more in-depth ASP.Net routing examples, you can look at the documentation here

Update: After looking at the example library in question (NopCommerce), it would appear they are using an explicit area registration. This is found in 'src/Presentation/Administration/AdminAreaRegistration.cs' :

using System.Web.Mvc;

namespace Nop.Admin
{
    public class AdminAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "Admin";
            }
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "Admin_default",
                "Admin/{controller}/{action}/{id}",
                new { controller = "Home", action = "Index", area = "Admin", id = "" },
                new[] { "Nop.Admin.Controllers" }
            );
        }
    }
}

Hopefully this gives you a better idea of how this is done.

Sign up to request clarification or add additional context in comments.

2 Comments

Have you check ever the nopcommerce app if you not so please check that if you'll get configuration then please reply.
If you look at the code for nopcommerce, under src/Presentation/Nop.Web/Administration, there is a file called 'AdminAreaRegistration.cs' It would appear that they are using an area for this after all.
0

This tutorial has cleared my confusion that how to configure more then one project in asp.net mvc as area.

http://nileshhirapra.blogspot.no/2012/02/aspnet-mvc-pluggable-application.html?m=1

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.