Parameters in ASMX webmethod

m2022 11 Reputation points
2023-01-03T15:02:53.197+00:00

I have a WebMethod in plain old asmx Webservice which accepts a couple of parameters in json format
eg
{"param1":1, param2="string"}
however if the sender attaches additional parameters in the list eg
{"param1":1, param2:"stringValue", "param3":3}, the webmethod is still invoked and returns result based on the two parameters.
Is there any way to return a 404 response when the input param list is not matching the webmethod list

Developer technologies | ASP.NET | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Lan Huang-MSFT 30,206 Reputation points Microsoft External Staff
    2023-01-04T06:58:53.917+00:00

    Hi @m2022 ,
    You didn't provide the code you're currently working on, we can only guess.
    I wrote a simple example according to your needs. Returns NotFound when param3 is empty.
    275856-image.png
    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.