Last post May 15, 2019 05:13 PM by Energie Design
May 14, 2019 08:34 PM|Energie Design|LINK
When under NET Core 2.1 web app these two of the same image load properly, however when under Net Core 2.2 the first image load properly which is expected but the second is not where it should. Failed to load resource: the server responded with a status
of 404 (Not Found) which is false. This is related to the encode uri and sub folders, but why was that working before and not anymore. What am'I missing?
<img src="/images/New folder/New folder/office365FeaturesIssue4.jpg" />
<img src="/images/New%20folder%2FNew%20folder%2Foffice365FeaturesIssue4.jpg" />
I don't want and can't use this @System.Uri.UnescapeDataString("") which would solve the issue.
<img src="@System.Uri.UnescapeDataString("/images/New%20folder%2FNew%20folder%2Foffice365FeaturesIssue4.jpg")" />
Also my _Layout.cshtml include this already for encoding
<meta charset="utf-8" />........
Using Visual Studio 2019 RC latest release.
May 15, 2019 12:28 AM|bruce (sqlwork.com)|LINK
must been a bug in 2.1 that was corrected in 2.2. %2f is used to escape a "/", so it is not a path separator. so the in second, the /'s are part of the filename, not path seperators,
unless the filename really is "New folder/New folder/office365FeaturesIssue4".jpg, then its a bug in 2.2. but using slashes (forward or back) in filenames should be avoided.
May 15, 2019 02:06 AM|Energie Design|LINK
The filename is office365FeaturesIssue4.jpg, and everything in front is the path where the file reside so "New Folder/New Folder/…." . The '%2F' is the path separator which in reality is '/'. so it works fine in 2.1 but a bug in 2.2
I guess. I tested it on a very basic web core app straight from VisualSudio 2019 and nothing else.
May 15, 2019 11:57 AM|Sherry Chen|LINK
Hi Nicolas ,
1. Any url is a kind of complete address to some resource(file) in network. But according to the rules of how it must be actually (to work as you expect), its expected that a
few characters must have some specific meaning; just like in this case: "/" means a separator that separates the individual elements of your address(url). So, "/" is actually a seperator, but "%2f" becomes
an ordinary character that simply represents "/" character in element of your url. You should not change the path separator.
2. From debugging on the source code of Asp.net Core, it does not seem to be a bug , but by design . Reasons are as follows:
Firstly ,The Asp.Net Core team designed to skip "%2f" in UrlDecoder.cs before generating Http ( or Httpcontext ) , you could refer to https://github.com/aspnet/KestrelHttpServer/blob/5d80016b4fb991acf6f639549b784ed5882d8de0/src/Kestrel.Core/Internal/Http/UrlDecoder.cs#L324
Secondly, according to the commit history on [GitHub](https://github.com/aspnet/HttpAbstractions/commit/0da88e0dda36d48ae68ac24289c349605cd94828#diff-a53064f49ddacce4c10371dc9e164fd9),
the ASP.NET Core team tends to prevent any double decoding behavior. That's means the `%2F` should not be decoded at all even during serving static files .
Best Regards ,
May 15, 2019 01:27 PM|Energie Design|LINK
Very nice explained answer.
Actually that image path is return from the usage of Telerik Kendo Core ImageBrowser control. So I don't have any control over that when it dump the image into the Editor control. This is the path structure that is return. But this works fine up to ASPNET
Core 2.1 and the ASPNET Core 2.2 or 3 are not working anymore.
May 15, 2019 01:50 PM|PatriceSc|LINK
And this is an actual file or served through a controller ?
You have the same issue if you take a location on your site that works and then replace a single / character somewhere by %2F
May 15, 2019 02:08 PM|bruce (sqlwork.com)|LINK
then it's a bug in the Kendo code (hidden a bug in 2.1). Report an issue. using %2F in a url makes the / part of the file segement rather segment separator.
May 15, 2019 05:13 PM|Energie Design|LINK
The problem seem to be the creation of the Web ASPNET Core project which is configuring with inProcess.
by removing the <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> it does now works fine.