Search code examples
c#asp.net.netweb-servicesasmx

ASMX service that receive a QRcode string in parameters miss some characters


I've got this method :

[WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        //[SoapHeader("User", Required = true)]
        public void GetValidationTicket(int idDispositivo, string QRCode, int tipologiaDispositivo, int profiloDispositivo)

that allow me to receive a QRCode of a ticket like this :

APGMDAwMjgzMjc4MmSlaRVkpXqpAU1JU2SlaRhlbiBBMX%2BL8s92v6u5ssAmqFODq8pqH8yZ04YI%2B0KYINjpj9E2tgiOHUyI3RKufv45HcQcM24gyUz8k1FF6xdAy0VDDdg%3D

As you see the QRCode have the special character '%' inside, and this is the problem, cos i need to convert it in base 64 string

Any Idea of the problem? mine or the caller? thanks

I expect a QRCode like EDAMDAwMjgzNjIwNWSmlmJkpqf2AU1JU2SmmEppdCBBMYVTqDlR7YhGvD6GAcKzTZQl6VGT/gbAOdXbeCL3c++FETwDjL5CqjnyhbLsaTNbO5Cz1lstuAqH8FTa9Jhg1jA=


Solution

  • Your QR code is URL encoded. Use HttpUtility.UrlDecode to decode it.

    https://learn.microsoft.com/en-us/dotnet/api/system.web.httputility.urldecode?view=net-7.0

    %2B = '+'

    %3D = '='

    You can test this online at a site like this one: https://www.urldecoder.org/