Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Web API Routing

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 327
    Comment on it

    Basics for Web API Routing

    1. The Web API framework maps incoming requests to the appropriate action based upon the HTTP verb of the request.
    2. The Web API route URLs to a controller, and then to the action which matches the HTTP verb of the request message. Action methods on the controller must either match the HTTP action verb, or at least include the action verb as a prefix for the method name.
    3. The default route template for a Web API Project is {controller}/{id} where the {id} parameter is optional. For example -

      i). http://apidomain/values i.e.

      GET api/values - it included as a part of an HTTP GET message that map to Get() mehtod

      ii). http://apidomain/values/5 i.e.

      // GET api/values/5 - it included as a part of an HTTP GET messag that map to Get(id) method

    4. Web API route templates may optionally include an {action} parameter. However, the action methods defined on the controller must be named with the proper HTTP action verb as a prefix in order for the routing to work.
    5. In matching incoming HTTP messages to controllers, the Web API framework identifies the proper controller by appending the literal "Controller" to the value of the {controller} route parameter, then scans the project for a class matching that name.
    6. Actions are selected from the controller by considering the non-complex route parameters, and matching them by name to the arguments of each method which matches the HTTP verb of the request.
    7. URLs in Web API cannot contain complex types. Complex types must be placed in the HTTP message body.

    References

    http://www.codeproject.com/Articles/624180/Routing-Basics-in-ASP-NET-Web-API

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: