Blazor WASM - cannot pass negative parameter to pages after publish

arik toledano 1 Reputation point
2022-05-16T11:11:07.357+00:00

Hi,
I Blazor WASM .net 6 visual studio 2022
I am trying to pass a negative parameter between pages but it doesn't work - it always pass an extra string '%E2%80%8E' at the beginning
for example if I pass -33333
http://localhost:8082/Counter/%E2%80%8E-33333
if I pass positive number then if works
Now the weird thing is that in debug IT DOES WORK :) - http://localhost:8082/Counter/-33333
but when I publish it to IIS then it disrupts the parameter and add the '%E2%80%8E'
this is just an example but In my real app I do pass negative parameter and it breaks it - it used to work on .net core 3.1.

I am adding screen shots to show you the problem +
the code which is basically nothing - I modified the 2 files from razor suffix to txt so they can be uploaded
202322-issuepassingnegativeparameter-afterpublish.jpg202277-issuepassingnegativeparameter-indebug-working.jpg
Thanks
Arik

202255-counter.txt

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,390 questions
{count} votes

2 answers

Sort by: Most helpful
  1. arik toledano 1 Reputation point
    2022-05-17T10:58:52.287+00:00

    Refining the scenario Thanks to AgaveJoe

    on IIS

    • it runs on Edge
    • it runs on firefox
    • it fails on chrome - even after disabled all plugins - Version 101.0.4951.67 (Official Build) (64-bit)
    0 comments No comments

  2. Björn 0 Reputation points
    2023-11-02T17:49:53.2133333+00:00

    Here's the solution for anyone coming across this post in the future like me. You need to "clean" the int value so it's culture specific before passing it to the NaviateTo function.

            int x = -123456789;
            var cleaned = x.ToString(CultureInfo.CreateSpecificCulture("en-us"));
                NavigationManager.NavigateTo("counter/" + cleaned);
    
    0 comments No comments