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

View: 18105|Reply: 0

[WebAPI] Asp.Net Mvc4 Webapi to get all the get parameters

[Copy link]
Posted on 2/17/2017 12:03:46 PM | | |

Recently, I used the WEBAPI in mvc4, and found that the receiving parameters are not very convenient, which is very different from the traditional request.querystring and request.form, and I searched a lot on the Internet, and there are various solutions, but not too detailed, so I tracked the variables in the Action, looked carefully, and finally found the solution, the following is the code:
Request in WEBAPI is of type HttpRequestMessage, and cannot have querystring and from method receiving parameters like the traditional web, and the base class of traditional HttpReqest is HttpReqestBase

So here we will directly use (HttpContextBase)Request.Properties["MS_HttpContext")





Previous:C# Factory Schema Code Generator Source Code
Next:The webapi setting returns JSON data by default
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