mukeshrawat
Posts: 3
Joined: Tue Oct 15, 2019 11:14 pm

How do I configure server-side serial number validation using .NET Web API

Hi,

I am using .NET core 2.2 API and with that trying to run server-side serial number validation. I saw the PHP implementation where for invalid key we are returning:

Code: Select all

return LICENSE_INVALID . $msg_sep . "Serial Number: " . $posted_serial . ' is invalid !';
What will be the equivalent for .NET Web API?
I tried below options but none working:

Code: Select all

return Ok(new { AnswerCode = 602, Message = "The serial number is invalid" }); 
return StatusCode(602, "The serial number is invalid");
return Ok("602\r\nThe serial number is invalid");
My Complete .Net code is:

Code: Select all

[HttpPost]
        public async Task<IActionResult> VerifyKey(string key)
        {
            try
            {
               var response = await VerifyKeyFromDb(key);
                if(response == null)
                {
                    return Ok("602\r\nThe serial number is invalid");
                }
                return Ok(601);
            }
            catch (Exception e)
            {
               // exception code
            }
        }
Any help would be appreciated.
Catalin
Posts: 6585
Joined: Wed Jun 13, 2018 7:49 am

Re: How do I configure server-side serial number validation using .NET Web API

Hello and welcome to Advanced Installer forums,

Unfortunately, I am not so experienced in what regards the usage of .NET Web API.

However, at a first glance, I think that you are returning a wrong result. Could you please try to just return "601", respectively "602" (not quite sure why you are returning Ok("602\r\nThe serial number is invalid")?

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mukeshrawat
Posts: 3
Joined: Tue Oct 15, 2019 11:14 pm

Re: How do I configure server-side serial number validation using .NET Web API

Hi,

Thanks for your reply. As per your documentation, for invalid serial key Advance installer expecting 602.
https://www.advancedinstaller.com/user- ... -page.html
AnswerCode\nMessage
"Message" is an explanatory message, "\n" is the new line character and "AnswerCode" must be one of:

601 - Serial number is valid. The Advanced Installer validation tool will allow the installation to continue. If an SKU needs to be selected then the "Message" should contain the desired SKU ID or name.
602 - Serial number is invalid. The Advanced Installer validation tool will not allow the installation to continue and will display a message box containing the explanatory message provided by your server.
Catalin
Posts: 6585
Joined: Wed Jun 13, 2018 7:49 am

Re: How do I configure server-side serial number validation using .NET Web API

Hello,

Indeed, you are right, the response should either be "601" or "602". However, in your case, I see that you are returning Ok("601)".

I am not quite sure what that "Ok" is for. Could you please try to return only the value and see if that helps? E.g:

Code: Select all

return 601;
Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mukeshrawat
Posts: 3
Joined: Tue Oct 15, 2019 11:14 pm

Re: How do I configure server-side serial number validation using .NET Web API

That is the Controller Action Return types in ASP.NET Core web API. It has to wrap in the return types and cannot be sent directly like

Code: Select all

return 601;  
Catalin
Posts: 6585
Joined: Wed Jun 13, 2018 7:49 am

Re: How do I configure server-side serial number validation using .NET Web API

Hello,

Indeed, I've further investigated this and you are right, that is a controller action return type on .NET Web API.

As mentioned earlier, unfortunately, I am not experienced in what regards the .NET Web API, so I am afraid it'll be hard for me to further assist in this regard.

However, just out of curiosity, how are you checking the status returned by your web server?

Best regards.
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”