Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asp.net core 3.1 - BreadCrumbAttribute don't file default Action of Controller #16

Closed
fjourde opened this issue Mar 25, 2020 · 2 comments

Comments

@fjourde
Copy link

fjourde commented Mar 25, 2020

Summary of the issue

A typical Controller

[BreadCrumb(Title="Pool Manager", Order = 0, UseDefaultRouteUrl = true)]
public class ManagePoolController : Controller {

[BreadCrumb(Title="List of pool",  Order = 1 )]
public IActionResult Index()
 {
// code
}
public [BreadCrumb(Title="Create a pool",  Order = 1 )]
public IActionResult Create(){
// some code
}

}

When the BreacCrumbAttribute is called on the Controller class Annotation, the followind method (getDefaultControllerActionUrl) return incorect Value :

The getDefaultAction(filterContext) don't return "Index" as in Asp.net core 2.1, because contextFilter.RouteData is not set.

So the breadcrumb don't display Link for "Pool Manager".
Home / Pool Manager / Create a pool

In Asp.net 2.1, Pool Manager is a link to /PoolManager/Index

private string getDefaultControllerActionUrl(ActionExecutingContext filterContext)
        {
            var defaultAction = getDefaultAction(filterContext);
            var urlHelper = getUrlHelper(filterContext);

            if (RemoveAllDefaultRouteValues)
            {
                return urlHelper.ActionWithoutRouteValues(defaultAction);
            }

            if (RemoveRouteValues == null || !RemoveRouteValues.Any())
            {
                return urlHelper.Action(defaultAction);
            }

            return urlHelper.ActionWithoutRouteValues(defaultAction, RemoveRouteValues);
        }

So the

Environment

DNTBreadCrumb.Core version: 1.9.1
.NET Core SDK version: 3.1
IDE: Visual Studio
@VahidN
Copy link
Owner

VahidN commented Mar 25, 2020

Fixed it via #4a4db10

@VahidN VahidN closed this as completed Mar 25, 2020
@lock
Copy link

lock bot commented Jun 24, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related problems.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants