Base solution for your next web application

Activities of "langman66"

I used the Sample project from here as a starting point.

<a class="postlink" href="https://github.com/aspnetboilerplate/module-zero/tree/master/sample">https://github.com/aspnetboilerplate/mo ... ter/sample</a>

If you need to make Authorized requests against your Application Layer Api's then what I do is 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.

You can see any example of the Sample AccountController here: <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero/blob/master/sample/ModuleZeroSampleProject.Web/Controllers/AccountController.cs">https://github.com/aspnetboilerplate/mo ... troller.cs</a>

To hit your MVC or WebAPI endpoints from other applications (mobile devices, 3rd party websites) you have to setup CORS. What I do is bring in the Asp.net Nuget packages for CORS.

You do not have to required your API endpoints to be authorized. You can do so by removing the AbpAuthorize attribute from either you Application class or MVC controller class.

Here's an example of my Application Layer controller requiring authorization. [AbpAuthorize] public class CampaignsAppService : CaptureApplicationServiceBase, ICampaignsAppService

Here's an example of my Application Layer controller allowing anonymous access.

public class LookupsAppService : CaptureApplicationServiceBase, ILookupsAppService {

I'm not sure if it will help you to an example of my website that is built based off the Abp framework and Zero module. You can see the javascript and usage of both a traditional MVC application and SPA.

<a class="postlink" href="http://www.capturedog.com">http://www.capturedog.com</a>

Hope this helps.

Chris

I ended up putting this in my constructor protected CaptureWebViewPageBase(){

        if (LocalizationManager == null)
        {
            LocalizationManager = IocManager.Instance.Resolve&lt;ILocalizationManager&gt;();                
        }

            Languages = LocalizationManager.GetAllLanguages();
            CurrentLanguage = LocalizationManager.CurrentLanguage;

}

Still not sure if this is the best approach, but it works for now :-)

I'm using ABP framework in a MVC and SPA application. The front-end application is MVC to benefit from SEO.

My application supports multiple languages (thanks to Abp awesome framework).

What I need to do is build a dynamic header menu for different language supported on the _Layout.cshtml base razor layout page.

In my _Layout.cshtml, I split my top menu into a Partial.

@Html.Partial("_TopBar")

Every page uses the _Layout.cshtml for their base template (Index.cshtml, Contact.cshtml, etc.).

Below is my _TopBar.cshtml partial page.

Question:

In my base MVC page public abstract class CaptureWebViewPageBase<TModel> : AbpWebViewPage<TModel>

I'm trying to use Property injection to get an public ILocalizationManager LocalizationManager { get; set; } but this object is not being set.

If I use constructor injection, then I get compile errors telling me "CaptureWebViewPageBase<TModel> doesn't contain parameterless constructor."

How can I inject the a ILocalizationManager into this page or am I doing this totally the wrong way?

Thanks so much for the guidance.

<div class="pre-header">

&lt;div class=&quot;container&quot;&gt;
    &lt;div class=&quot;row&quot;&gt;
        
        &lt;div class=&quot;col-md-6 col-sm-6 additional-shop-info&quot;&gt;
            &lt;ul class=&quot;list-unstyled list-inline&quot;&gt;
                &lt;li&gt;
                    &lt;i class=&quot;fa fa-envelope-o&quot;&gt;&lt;/i&gt;
                    &lt;span&gt;
                        &lt;a href=&quot;mailto:[email protected]&quot;&gt;[email protected]&lt;/a&gt;
                    &lt;/span&gt;
                &lt;/li&gt;
            &lt;/ul&gt;
        &lt;/div&gt;
        

        
        &lt;div class=&quot;col-md-6 col-sm-6 additional-nav&quot;&gt;
            &lt;ul class=&quot;list-unstyled list-inline pull-right&quot;&gt;

                @using Microsoft.AspNet.Identity
                @if (Request.IsAuthenticated)
                {
                    &lt;li&gt;@Html.ActionLink(L("MyAccount"), "Dashboard", "App")&lt;/li&gt;
                    &lt;li&gt;@Html.ActionLink(L("Logout"), "Logout", "Account", routeValues: null, htmlAttributes: new { id = "logoutForm", target = "_self" })&lt;/li&gt;
                }
                else
                {
                    &lt;li class=&quot;dropdown dropdown-language&quot;&gt;
                        &lt;a class=&quot;dropdown-toggle&quot; dropdown-menu-hover data-toggle=&quot;dropdown&quot; data-close-others=&quot;true&quot;&gt;
                            &lt;i&gt;&lt;/i&gt;
                            &lt;span class=&quot;langname&quot;&gt;@L(@CurrentLanguage)  &lt;/span&gt;
                            &lt;i class=&quot;fa fa-angle-down&quot;&gt;&lt;/i&gt;
                        &lt;/a&gt;
                                                    
                        &lt;ul class=&quot;dropdown-menu dropdown-menu-default&quot;&gt;
                                @foreach (var language in Languages)
                                {
                                    &lt;li class=&quot;active&quot;&gt;
                                        &lt;a href=&quot;/AbpLocalization/[email protected]&quot;&gt;
                                            &lt;i class=&quot;@language.Icon&quot;&gt;&lt;/i&gt; @L(language.DisplayName)
                                        &lt;/a&gt;
                                    &lt;/li&gt;
                                }                                
                        &lt;/ul&gt;

                    &lt;/li&gt;

                    &lt;li&gt;
                        @Html.ActionLink(@L("Login"), "Login", "Account")
                    &lt;/li&gt;
                }

            &lt;/ul&gt;
        &lt;/div&gt;
        
    &lt;/div&gt;
&lt;/div&gt;

</div>

How are you attempting to use the modal? Are you using an AngularJS based clientside framework?

Please post some sample code or a shared link on a service like <a class="postlink" href="http://plnkr.co/">http://plnkr.co/</a> and I'm sure someone will assist you.

I have navigation menus for my public facing website (typical stuff like Home, Contact Us, About, Login) and then once the user logs into the internal application I have menus like (Dashboard, Profile, Campaigns, etc.).

Here's how I've built the different menus in my NavigationProvider.

//This is the "MainMenu".

            context.Manager.MainMenu
                .AddItem(
                    new MenuItemDefinition(
                        "Home",
                        new LocalizableString("HomePage", CaptureConsts.LocalizationSourceName),
                        url: "/",
                        icon: "fa fa-home"
                        )
                )
                .AddItem(
                    new MenuItemDefinition(
                        "About",
                        new LocalizableString("About", CaptureConsts.LocalizationSourceName),
                        url: "/Home/About",
                        icon: "fa fa-cog"
                        )
                )                
                .AddItem(
                    new MenuItemDefinition(
                        "Contact",
                        new LocalizableString("Contact", CaptureConsts.LocalizationSourceName),
                        url: "/Home/Contact",
                        icon: "fa fa-info"
                        )
                .AddItem(
                    new MenuItemDefinition(
                        "Login",
                        new LocalizableString("Login", CaptureConsts.LocalizationSourceName), url: "/Account/Login",
                        icon: "fa fa-info"                                
                    ))
                );


//This is the "Dashboard" menu.

            var dashboardMenuDefinition = new MenuDefinition("Dashboard", new LocalizableString("Dashboard", CaptureConsts.LocalizationSourceName));


            var dashboardMenuItemDefinition = new MenuItemDefinition(
                "Dashboard",
                new LocalizableString("Dashboard", CaptureConsts.LocalizationSourceName), url: "/app/dashboard",
                icon: "icon-home");

            var campaigns = new MenuItemDefinition(
                "Campaigns",
                new LocalizableString("Campaigns", CaptureConsts.LocalizationSourceName), url: "javascript:;",
                icon: "icon-settings")
                .AddItem(
                    new MenuItemDefinition(
                        "AllCampaigns",
                        new LocalizableString("AllCampaigns", CaptureConsts.LocalizationSourceName),
                        url: "/app/campaigns", icon: "icon-puzzle"
                        ))
                .AddItem(
                    new MenuItemDefinition(
                        "CreateCampaign",
                        new LocalizableString("CreateCampaign", CaptureConsts.LocalizationSourceName),
                        url: "/app/campaigns/0/edit", icon: "fa fa-file-o"
                        ));
                //.AddItem(
                //    new MenuItemDefinition(
                //        "CreateCampaign",
                //        new LocalizableString("CreateCampaign", CaptureConsts.LocalizationSourceName),
                //        url: "/app/campaigns/createedit", icon: "fa fa-file-o"
                //        ));
            //url: "/app/campaign/:campaignId/edit",
            
            var userProfile = new MenuItemDefinition(
                "UserProfile",
                new LocalizableString("UserProfile", CaptureConsts.LocalizationSourceName), url: "/app/userprofile/account",
                icon: "icon-user");


            dashboardMenuDefinition.AddItem(dashboardMenuItemDefinition);
            dashboardMenuDefinition.AddItem(campaigns);
            dashboardMenuDefinition.AddItem(userProfile);

            context.Manager.Menus.Add("Dashboard", dashboardMenuDefinition);

The javascript object structure looks like the following, which you will see in the AbpScripts/GetScripts api call.

(function() {
    abp.nav = {};
    abp.nav.menus = {
        'MainMenu': {
            name: 'MainMenu',
            displayName: 'Main menu',
            items: [{
                    name: 'Home',
                    icon: 'fa fa-home',
                    url: '/',
                    displayName: 'Home page',
                    items: []
                } , {
                    name: 'About',
                    icon: 'fa fa-cog',
                    url: '/Home/About',
                    displayName: 'About',
                    items: []
                } , {
                    name: 'Contact',
                    icon: 'fa fa-info',
                    url: '/Home/Contact',
                    displayName: 'Contact',
                    items: [{
                            name: 'Login',
                            icon: 'fa fa-info',
                            url: '/Account/Login',
                            displayName: 'Login',
                            items: []
                        }]
                }]
            }
 ,         'Dashboard': {
            name: 'Dashboard',
            displayName: 'Dashboard',
            items: [{
                    name: 'Dashboard',
                    icon: 'icon-home',
                    url: '/app/dashboard',
                    displayName: 'Dashboard',
                    items: []
                } , {
                    name: 'Campaigns',
                    icon: 'icon-settings',
                    url: 'javascript:;',
                    displayName: 'Campaigns',
                    items: [{
                            name: 'AllCampaigns',
                            icon: 'icon-puzzle',
                            url: '/app/campaigns',
                            displayName: 'All Campaigns',
                            items: []
                        } , {
                            name: 'CreateCampaign',
                            icon: 'fa fa-file-o',
                            url: '/app/campaigns/0/edit',
                            displayName: 'Create Campaign',
                            items: []
                        }]
                } , {
                    name: 'UserProfile',
                    icon: 'icon-user',
                    url: '/app/userprofile/account',
                    displayName: 'User Profile',
                    items: []
                }]
            }
    };
})();

My application service call will read .css and .js files from disk, perform some customizations to the content, then generate and minified output file.

When using MVC or WebAPI, I usually just use the HttpContext to figure out my paths such as:

var pathToCssWidget = HttpContext.Server.MapPath("~/Content/");

How would I go about getting access to the HttpContext from a class derived from the ApplicationService?

Thanks,

Chris

Showing 1 to 6 of 6 entries