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

Partial view depth 2 throws 404 #806

Closed
Abdjulaziz opened this issue Jul 20, 2024 · 7 comments
Closed

Partial view depth 2 throws 404 #806

Abdjulaziz opened this issue Jul 20, 2024 · 7 comments
Labels

Comments

@Abdjulaziz
Copy link
Member

Abdjulaziz commented Jul 20, 2024

Partial view depth 2 throws 404

Files that are two levels deep in any folder under templates ↓ trow ApiError Not Found
image
image

I've had the issue with:
14.0.0
14.1.0
14.1.1

The random thing is it throws an error it cannot access the files and create files but it is able to create files but they are not accessible and give this error:
image

Issue description

related to this issue, that should have been fixed but still presists on cloud: umbraco/Umbraco-CMS#16249

@mikkelhm
Copy link
Member

Hey @Abdjulaziz What version of Umbraco did you try this out in ? was it a 14.0 or the 14.1 version?

@Abdjulaziz
Copy link
Member Author

14.0.0
14.1.0
14.1.1

@lars-lindstrom
Copy link

lars-lindstrom commented Jul 25, 2024

I can add
14.2.0--rc.preview.9.g7e444e5

The problem could be related to translation of "/" into "%2F" or vice-versa

@Abdjulaziz
Copy link
Member Author

Still an issue on 14.3.0

@JJong-nl
Copy link

JJong-nl commented Oct 10, 2024

This also happens on stylesheets and scripts within folders.
This is because umbraco is using an illigal character in the path. (%2F). When the host is configured for correcting this, umbraco fails. (for example Azure WebApps are correcting this). But the raw PathAndQuery is placed in the X-Waws-Unencoded-Url.)

A Host sulution is adding middleware for restoring the 'raw' path value.
Otherwise, umbraco should encode the {path} part or placing the parameter outside the path and in the querystring

middleware example: (works on Azure)

    public class RestoreRawRequestPathMiddleware
    {
        private const string UnencodedUrlHeaderName = "X-Waws-Unencoded-Url";
        private readonly RequestDelegate _next;

        public RestoreRawRequestPathMiddleware(RequestDelegate next)
        {
            _next = next;
        }

        public async Task Invoke(HttpContext context)
        {
            if (context.Request.Headers.TryGetValue(UnencodedUrlHeaderName, out var unencodedUrlValue) && unencodedUrlValue.Any())
            {
                if (Uri.TryCreate($"https://fake.uri{unencodedUrlValue.First()}", UriKind.Absolute, out var uri))
                {
                    context.Request.Path = new PathString(uri.AbsolutePath);
                }
            }
            await _next(context);
        }
    }

@JJong-nl
Copy link

Fix for umbraco-team. (i cant push the code)

Fix these files:

ByPathPartialViewFolderController.cs
ByPathPartialViewController.cs
ByPathScriptFolderController.cs
ByPathScriptController.cs
ByPathStylesheetFolderController.cs
ByPathStylesheetController.cs

Change the [HttpGet("{path}")] attribuut into [HttpGet("{*path}")] (see the asterix difference)

This was also done in the past for the ByPathMediaApiController

@Abdjulaziz
Copy link
Member Author

Fixed in v15 after the this implementation: #17468
Next v14 upgrade should also have the fix 😄

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

No branches or pull requests

4 participants