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

Relative URL prefixed with /Admin in case of an admin controller action if [Route] attribute is used (OSOE-653) #201

Closed
dministro opened this issue Jun 23, 2023 · 4 comments · Fixed by #208
Assignees
Labels

Comments

@dministro
Copy link
Member

dministro commented Jun 23, 2023

The relative URL created by the TypedRoute.ToString() for a controller action where the controller has [Admin] attribute and the action has [Route] gets prefixed with /Admin. I think the expected result is the URL is not prefixed with /Admin.

public override string ToString()
{
var prefix = _isAdminLazy.Value ? "/Admin/" : "/";
var route = _routeLazy.Value;
var arguments = _arguments.Any()
? "?" + string.Join('&', _arguments.Select((key, value) => $"{key}={WebUtility.UrlEncode(value)}"))
: string.Empty;
return prefix + route + arguments;
}

For the following example, the relative URL will be: /Admin/SampleModule/Admin/Edit

[Admin]
public class AdminController : Controller
{
    ...

    [Route("SampleModule/Edit")]
    public async Task<IActionResult> Edit(string contentItemId, string returnUrl)
    {
        ...
    }
}

Jira issue

@github-actions github-actions bot changed the title Relative URL prefixed with /Admin in case of an admin controller action if [Route] attribute is used Relative URL prefixed with /Admin in case of an admin controller action if [Route] attribute is used (OSOE-653) Jun 23, 2023
@Piedone Piedone added the bug label Jun 23, 2023
@Piedone
Copy link
Member

Piedone commented Jun 23, 2023

Just to confirm, this is only about actions with [Route], but without a manually defined route you still would expect the prefix, right?

@dministro
Copy link
Member Author

Yes, if the action (without [Route(...)] attribute) is a member of an admin controller (with [Admin] attribute) I would expect the /Admin prefix.

@dministro
Copy link
Member Author

I changed the route from SampleModule/Admin/Edit to SampleModule/Edit in the sample code in the issue description to make no confusion.

@Piedone
Copy link
Member

Piedone commented Jun 23, 2023

I see, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants