ASP. NET API

Source: Internet
Author: User

Parameter passing

Get Request Pass Parameter Problem summary:

1. Using GET requests only pass parameters via URL, essentially URL string concatenation, url string length is limited

2. Do not use the entity parameters, the background method defines the parameters, and the missing parameters in the request match is unsuccessful;

3. When using the entity parameter, the [Fromuri] attribute is required, the field in the entity parameter can not be passed, and the other parameters in the interface method must be passed

4. You can use multiple entity parameters at the same time, the same name is assigned to the URL parameter

5.Get type method name, should try to use "get+ method Name" naming method, and habitually before the method with [httpget characteristics]; The interface method name does not start with Get, you must add the [HttpGet] property to match the success.

Post request delivery parameter issues Summary:

1. A single parameter (such as a string parameter) needs to use the [Frombody] property, which will appear 404 if not used;

The jquery Post parameter takes the form {": ' ADC '} to accept the parameter successfully, while the applet does not receive the parameter in the same way.

A parameter in the interface method, the Jqpost parameter is {': ' abc ', ': ' BCD '} (the parameter name is the same) and the view HTTP request discovery will only pass the latter one, and the received parameter is the latter one.

2. Use the dynamic type parameter jqpost parameter {"Key1": "abc", "Key2": "BCD"} interface method using [Frombody] and the dynamic keyword, do not use [frombody] can also be successfully passed, in order to standardize the best marked

3. Use the entity parameter Jqpost parameter {"Key1": "abc", "Key2": "BCD"} interface method using [Frombody]

4. Set parameters JQ Post parameters

var param=[{"Key1": "abc", "Key2": "BCD"},{"Key1": "abc", "Key2": "BCD"},{"Key1": "abc", "Key2": "BCD"}];d Ata:param, The interface method parameter is ilist<> type parameter, omitting [Frombody] parameter can receive success 5. Array parameter jq Post parameter var Param = ["1", "2", "3"];d Ata:param, interface method parameter is string[] ARR, omitting the [frombody] parameter can receive a success of 5. The POST request passes the parameter through the request body, the relative GET request security; Post has no parameter length limit, the GET request URL has a limit (general 1024b) specification: For the Controller method, as far as possible to refer to the canonical format, such as the corresponding controller method to add the corresponding HTT request (get corresponding [ Httpget],post corresponding to [HttpPost]), the method name as far as possible in the "HTTP Please type + method name" format (such as Get request, recommended to use Get+methodname;post request corresponding post+methodname);

ASP. NET API

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.