Skip to content

UseStaticFiles does not work with spaces encoded as plus signs #64260

@miloush

Description

@miloush

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

app.UseStaticFiles() returns 404 for file names that contain spaces and the browser requests them using + rather than %20.

Such links are easy to come across since HttpUtility.UrlEncode uses + to encode spaces. HttpUtility.UrlPathEncode which encodes spaces as %20 is documented as do not use.

Expected Behavior

The + sign to be decoded into space and the files served.

Steps To Reproduce

  1. Create a new ASP.NET project
  2. Put a file with space in the wwwroot folder.
  3. Request it using + for space.

Exceptions (if any)

No response

.NET Version

10.0.100-rc.2.25502.107

Anything else?

Running on Microsoft.AspNetCore.App 8.0.21.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresfeature-static-files

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions