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

Async Actions Not Recognized with 'Async' Suffix #109

Open
aAboodi opened this issue Apr 24, 2024 · 0 comments
Open

Async Actions Not Recognized with 'Async' Suffix #109

aAboodi opened this issue Apr 24, 2024 · 0 comments

Comments

@aAboodi
Copy link

aAboodi commented Apr 24, 2024

It appears that the SmartBreadcrumbs functionality does not recognize asynchronous actions that have an Async suffix in their names. While the actions work as expected, the breadcrumb feature fails to display them when the Async suffix is present, even if the method is declared with the async keyword.

For instance:

Not Recognized: The breadcrumb does not show the action Details:

[Breadcrumb("Details")]
public async Task<IActionResult> DetailsAsync(int id, string ln = "")
{   // codes with await keywords   }

Recognized: The breadcrumb correctly displays the action Details:

[Breadcrumb("Details")]
public async Task<IActionResult> Details(int id, string ln = "") 
{   // codes with await keywords   }

A similar issue occurred when attempting to make the Index action (default) of a HomeController asynchronous by naming it IndexAsync(). Despite not adding any annotations, the exception was triggered, likely due to the presence of a [DefaultBreadcrumb("Home")]] annotation above the controller class. However, it's puzzling why IndexAsync() wasn't recognized as an Index action, considering the controller and view treated it as such.

The exception message received was:

SmartBreadcrumbs.SmartBreadcrumbsException: 'HomeController doesn't contain a valid action named Index.

The exception was triggered at program.cs in the following line:

builder.Services.AddBreadcrumbs(Assembly.GetExecutingAssembly(), options =>
{
	options.TagName = "";
	options.TagClasses = "";
	options.OlClasses = "breadcrumb justify-content-center mb-0";
	options.LiClasses = "breadcrumb-item";
	options.ActiveLiClasses = "breadcrumb-item active text-white";
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant