Search code examples
.netasp.net-coreurlwhitespace

%E2%80%8B Appears in url .Net Core


I never experienced such issue, but it appears as part of route and if I manually enter route then the result is 404.

If I copy from swagger %E2%80%8B appears.

How can I fix this issue?

.Net Core 2.1

http://localhost/functionCodes/%E2%80%8Btest - works

http://localhost/functionCodes/test - 404


Solution

  • As per: this chart

    %E2%80%8B is the code for a "ZERO-WIDTH SPACE" character.

    It has probably been inserted without you noticing it somehow, you probably can't see it in your code, but it is here.

    I recommend completely removing the string (including the surrounding quotes!) where the URL is defined and re-write it.

    Since you use ASP.NET, this path may come from the name of an Action method in a Controller, but the solution is the same: remove completely the name of the Test() method, making sure you delete some space characters before that, and rewrite-it.

    If you want to inspect this, you can probably use some advanced text editor or hexadecimal editor to view that it is actually in the source code.

    There may be some Visual Studio extensions that would help you view these hidden characters as well.