Base solution for your next web application

Activities of "lcyhjx"

a sample for building sub-menu Question Administration ----Users

Sample code in NavigationProvider

context.Manager.MainMenu
                .AddItem(
                    new MenuItemDefinition(
                        "Questions",
                        new LocalizableString("Questions", BOMConsts.LocalizationSourceName),
                        url: "#/questions",
                        icon: "fa fa-question"
                        )
                )
                 .AddItem(
                 new MenuItemDefinition(
                    "Administration",
                    new LocalizableString("Administration", BOMConsts.LocalizationSourceName),
                    url:"",
                    icon: "fa fa-cogs"
                    ).AddItem(
                        new MenuItemDefinition(
                            "Users",
                            new LocalizableString("Users", BOMConsts.LocalizationSourceName),
                            url: "#/users",
                            icon: "fa fa-users"
                            )
                    )
                );

Routing in app.js:

//Configuration for Angular UI routing.
    app.config([
        '$stateProvider', '$urlRouterProvider',
        function($stateProvider, $urlRouterProvider) {
            $urlRouterProvider.otherwise('/questions');
            $stateProvider
                .state('questions', {
                    url: '/questions',
                    templateUrl: abp.appPath + 'App/Main/views/questions/index.cshtml',
                    menu: 'Questions' //Matches to name of 'Questions' menu in BOMNavigationProvider
                })
                .state('questionDetail', {
                    url: '/questions/:id',
                    templateUrl: abp.appPath + 'App/Main/views/questions/detail.cshtml',
                    menu: 'Questions' //Matches to name of 'Questions' menu in BOMNavigationProvider
                })
                .state('users', {
                    url: '/users',
                    templateUrl: abp.appPath + 'App/Main/views/users/index.cshtml',
                    menu: 'Users' //Matches to name of 'Users' menu in BOMNavigationProvider
                });
        }
    ]);

layout/header.cshtml

<ul class="nav navbar-nav">
                <li ng-repeat="menuItem in vm.menu.items" ng-class="{active: vm.currentMenuName == menuItem.name}">

                    <a ng-if="menuItem.items.length==0" ng-href="{{menuItem.url}}"><i class="{{menuItem.icon}}" ng-if="menuItem.icon"></i> {{menuItem.displayName}}</a>

                    <a ng-if="menuItem.items.length>0" href="" data-toggle="dropdown"><i class="{{menuItem.icon}}" ng-if="menuItem.icon"></i> {{menuItem.displayName}} </a>
                    <ul ng-if="menuItem.items.length>0" class="dropdown-menu">
                        <li ng-repeat="menuSubItem in menuItem.items">
                            <a ng-href="{{menuSubItem.url}}"><i class="{{menuSubItem.icon}}" ng-if="menuSubItem.icon"></i> {{menuSubItem.displayName}}</a>
                        </li>
                    </ul>

                </li>
            </ul>

Thanks langman66.

I have went through the sample project Module Zero. Yes as you said, it do hit the MVC AccountController Login action first that gives me back a token. The browser (or any other device has to ) will then send along all the token in the header values of each request to any APIs. Ok, then let’s see, In the sample project, we can get the token by hitting the MVC accountcontroller login action, but if I invoke the authorized web api in an console application by posting HttpWebRequest, how do I get the token and send the token in the header of the HttpWebRequest?

As my assume, If I need to get the token, I need to invoke an account/login web api to get it. But in the sample module zero project, it is a MVC accountcontroller login action. I have thought move the coding of MVC accountcontroller login action to web api/application layer, but the web api is dynamic generated in the abp framework, I have tried, but failed.

Look forward your advice, do you have a sample of invoking an authorized api in other application, such as an console application using post HttpWebRequest.

I get module zero, and run it. Then the address of question/getquestion web api is, <a class="postlink" href="http://localhost:6242/api/serivces/app/question/getquestion">http://localhost:6242/api/serivces/app/ ... etquestion</a>

If I invoke this web api in another application, such as a console application, a win form application or a mobility application, it return

<Response xmlns="http://localhost/API/SERVICES/app/question/getquestion"> <error> <code>0</code> <details null="true"/> <message>No user logged in!</message> <validationErrors null="true"/> </error> <result null="true"/> <success>false</success> <unAuthorizedRequest>true</unAuthorizedRequest> </Response>

I know I miss the authentication data in the request, but what authentication should I pass? I assume I need to invoke a user/login web api to get the authentication data, and then pass it in question/getquestion web api. Could you please give me some suggestion? Thanks so much.

Do you have any suggestion?

Hi, I get the Module Zero project, it works fine. Thanks. But I found that the instance of IAuthenticationManager is created in web layer. Since the WEB API may not only used by Web Application, may also use by other clients, such as mobile application. So I would like to move AuthenticationManager from web layer to Web API/Application layer. In normal way, I can get instance of IAuthenticationManager in Web API layer as following: private IAuthenticationManager Authentication { get { return System.Web.Http. ApiController.Request.GetOwinContext().Authentication; } } But in Abp Framework, the Web Api is built dynamic, I do not know how to get the instance of IAuthenticationManager in Applciation layer with Abp framework, could you please give me some advice?

Is there a way that I invoke the authenticated ASP.net Web API on Mobility side? For example, an android application or an HTM5 based mobility application?

Thanks. I will try.

Thanks Asp.Net Boilerplate first. I create a sample project from <a class="postlink" href="http://www.aspnetboilerplate.com">http://www.aspnetboilerplate.com</a> by using AngulatJS and Entity Framework, then I would like to change the navrbar with sub-menu as following: • Order • Report • Administration o User management (this is a sub-menu under Administration menu) So I make following changes in Navigation Provider class

context.Manager.MainMenu
                .AddItem(
                    new MenuItemDefinition(
                        "Order",
                        new LocalizableString("Order", BOMConsts.LocalizationSourceName),
                        url: "#/",
                        icon: "fa fa-tasks"
                        )
                )
                .AddItem(
                    new MenuItemDefinition(
                        "Report",
                        new LocalizableString("Report", BOMConsts.LocalizationSourceName),
                        url: "#/Report",
                        icon: "fa fa-bar-chart"
                        )
                )
                .AddItem(
                new MenuItemDefinition(
                    "Administration",
                    new LocalizableString("Administration", BOMConsts.LocalizationSourceName),
                    icon: "fa fa-cogs"
                    ).AddItem(
                        new MenuItemDefinition(
                            "UserManagement",
                            new LocalizableString("UserManagement", BOMConsts.LocalizationSourceName),
                           // url: "/Administration/Users",
                            icon: "fa fa-users"
                            )
                    )
                );

But when I run the project, the sub-menu 'User Management' does not display. Could you please let me know what am I missing? It is better to give me a sample code if it is possible, thanks.

My pleasure.

Not sure if following topic can help you or not, but for your reference.

#19

Showing 41 to 50 of 54 entries