1

I have two layout first for visitor second for management

Rout:

app.config(['$routeProvider',
        function ( $routeProvider) {
            $routeProvider
                .when('/', { templateUrl: 'Home/Main', })
                .when('/Manage', { templateUrl: 'Manage/Index', caseInsensitiveMatch: true })
                .when('/Manage/Item/:itemId?', { templateUrl: '/Item/Index/',caseInsensitiveMatch: true});
        }
      ]);

First ng-view in home/index and second ng-view in manage/index but /Item not loaded in manage ng-view

2 Answers 2

3

IMO areas in MVC pretty much suck. I hate the idea of duplicating most of your MVC app just to render a different layout.

In my situation, I have a layout for when the user hasn't been authenticated and another layout for when they have. In my case, I have an AngularJS SPA on top of an MVC app. Since it's a SPA, I have a single View with a <div ng-view></div> element. The solution I implemented utilizes the _ViewStart.chtml file:

@{
    if (User.Identity.IsAuthenticated) 
    {
        Layout = "~/Views/Shared/_Layout.cshtml";
    }
    else
    {
        Layout = "~/Views/Shared/_UnauthorizedLayout.cshtml";
    }
}

I'm using a conditional with the exposed IPrincipal object, but you could put whatever conditional logic you want in there.

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

Comments

1

add an area in your mvc project for your manage layout
then create your own route provider for manage layout

app.config(['$routeProvider',
        function ( $routeProvider) {
            $routeProvider
                .when('/', { templateUrl: 'Manage/Home/Main', })
                .when('/Manage', { templateUrl: 'Manage/Manage/Index', caseInsensitiveMatch: true })
                .when('/Manage/Item/:itemId?', { templateUrl: 'Manage/Item/Index/',caseInsensitiveMatch: true});
        }
      ]);

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.