Reputation: 1185
I am working on .NET Core 2.2 application (will be upgraded soon). There is a functionality to upload files on the server which can be accessed by other users via a link. Everything works pretty fine. There are checks to prevent files with certain characters including #
. The only issue I am having is, client is insisting to allow #
in filename. There are no issues when uploading such files, but it doesn't load via link. I get Status Code: 404; Not Found
error. This was the issue in legacy site (ASP.NET WebForms) as well where it was showing 404 - File or directory not found.
.
The URL I get looks like this: /_ClientData/NTTF/Announcements/61/Docs/invalid%20#%20test.pdf
As a last option, I can allow this files and replace #
with something else on server, but I am wondering if there is any way to make this work without manipulating filename.
Upvotes: 0
Views: 1169
Reputation: 121881
You probably have an Razor page (or equivalent) that dynamically generates the "clickable link".
SUGGESTION: Use HttpUtility.UrlEncode() to explicitly generate the link, as you serve the page.
It should generate something like this:
invalid # test.pdf
invalid%20%23%20test.pdf
Upvotes: 1