Specify the URL and parameters for access in the WebApiConfig.cs file (professional is to specify the route, using URLs is easier to understand)
public static void Register (HttpConfiguration config)
{
//config.MapHttpAttributeRoutes ();
config.Routes.MapHttpRoute (
name: "DefaultApi",
routeTemplate: "api / {controller} / {id}",
defaults: new {id = RouteParameter .Optional}
);
config.Routes.MapHttpRoute (
name: "DefaultApi1",
routeTemplate: "api / {controller} / {type} / {access_token} / {custId} / {org_item} / {startDate}", // here It is the url to access the controller, and the parameter type is the parameter name of the action method. Defaults
: new
{
type = RouteParameter.Optional,
access_token = RouteParameter.Optional,
custId = RouteParameter.Optional,
org_item = RouteParameter.Optional,
startDate = RouteParameter.Optional
}
);
Just where the custdata controller corresponds
[HttpGet] // Specify that get can be accessed here, just use Google Chrome to test it.
public HttpResponseMessage custdata(string type, string access_token, string custId = null, string org_item = null, string startDate = null)
{
// The specific party can write what he wants.
}
The specific test url: http: // localhost: 8701 / api / custdata? & Type = stock_io & access_token = 92a51d611b06bccc09a1b1018df32887 & startDate = 2017-04-01
The test here can be freely combined. In addition to type, access_token is a required parameter, the above is my study notes.