This article is a mirror article of machine translation, please click here to jump to the original article.

View: 21530|Reply: 0

[WebAPI] asp.net the webAPI to set optional parameters

[Copy link]
Posted on 4/20/2018 1:09:45 PM | | | |


The above is a method in the webapi controller, when simulating a get request, there will be no error with the above three parameters, if only the "CardNo" parameter is used, the error will be reported as follows:

{
    "Message": "No HTTP resource was found that matches the request URI 'http://localhost:28742/api/Driver/Test?CardNo=1'.",
    "MessageDetail": "No action was found on the controller 'Driver' that matches the request."
}




Solution:

For optional parameters, set default values, such as:



If there are more than three parameters, consider using a model.




Previous:zTree -- jQuery tree plugin
Next:HttpRuntime Cache reads set cache information encapsulation
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com