Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

ASP.Net Core MVC - Add menuitems from Database records #7960


User avatar
0
SBJ created

Hi,

We are trying to Add Items to our menu from a database entitie. If we try to getAll we get the exeption that the user was not logged in. And if you login the menu is already loaded so it does not get the call to the database.

As an example we created the Entitie Car so in the menu we have Car but as a submenu we would like to see all the cars that are available inside the database. Car Audi BMW Tesla

How can we create this type of menu dynamically?

We are using the latest version of ASP.Net Zero ASP.Net Core MVC 7.2.0


4 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    The design of the menu is the same as the permissions and settings. They are determined after the application is launched and cannot be dynamically modified during runtime.

    If we try to getAll we get the exeption that the user was not logged in.

    Please share your current implementation code.

    In fact, if abp's menu function can't fulfill your needs, you can customize a dynamic menu service and use your dynamic menu service to get the menu in the view.

  • User Avatar
    0
    SBJ created

    The problem with the GetAll is that we are not logged in yet and the menu is determined on launch not on login. So there is no connection with the database. It seems that we need to somehow add a dynamic menu service but I'm a bit confused how to implement this. Do you have any examples for this?

  • User Avatar
    0
    maliming created
    Support Team

    I think you can try to get custom menu information from the database here.

    https://github.com/aspnetzero/aspnet-zero-core/blob/40b33be309fc892f15ca9a0d8e7cf33b8a37fbfe/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Mvc/Areas/AppAreaName/Views/Shared/Components/AppAreaNameMenu/AppAreaNameMenuViewComponent.cs#L33

  • User Avatar
    0
    ismcagdas created
    Support Team

    This issue is closed because it has not had recent activity for a long time.