菜单
  
    Introduction to ASP.NET Web API Introduction ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. With Web API content negotiation, we can return data based on the client requests. What I mean is, if the client is requesting the data to be returned as JSON or XML, the Web API framework deals with the request type and returns the data appropriately based on the media type. By default Web API provides JSON and XML based responses.39923
    Web API is an ideal platform for building pure HTTP based services where the request and response happens with HTTP protocol. The client can make a GET, PUT, POST, and DELETE request and get the Web API response appropriately.
    In summary, the Web API is
    •    An HTTP Service
    •    Designed for broad reach
    •    Uses HTTP as an Application protocol, not a transport protocol
    Web API Architecture
    We shall see below the Web API architecture when you are hosting Web API in ASP.NET and self-hosting through console or Windows service.
    Routing configuration in Web API is slightly different from asp.NET MVC Routing. The Web API uses Http Route Collection and Route. The Web API team has reused the routing logic of MVC in Web API. The only reason why it’s a different routing is in order to keep the Web API from having its dependency onasp.NET Routing. The team decided to make it independent so that Web API will not haveasp.NET class dependencies and it can be hosted in console or a Windows service as self-hosting.
    While inasp.NET Web API Routing, the system will not only register the Http Route object but also it will create a wrapper Route object and in the asp.NET routing engine.
    The significant difference that you can see here is you will not have access to Routing data in message handlers when you are trying to access the same in self-hosting, the reason is the route configuration is set and it will run at a later point in the life cycle.
    The other significant difference between the API Controller and the normal MVC controller is with Web API , API Controller, the actions are dispatched by default based on the HTTP request. However there is a flexibility to override it so that the Web API will use the action name to select the action method within the API Controller.
    What is Content Negotiation in Web API
    This is something which you will here frequently in Web API. Content negotiation is the process of selecting the best representation for a given response when there are multiple representations available. The underling Web API framework implements the content negotiation and that is the reason why and how the client can request data with a specific media type.
    By default the Web API returns data in JSON format, however while requesting for a resource, we can specify the media type to return so that the Web API knows what you are requesting for and select the proper formatter to output the data.
    How to Implement Web API?
    We shall see a generic implementation of Web API.
    We have to create a class which derives from API Controller. The methods defined in the Web API controller map to the HTTP methods. If you have a method name prefixed with GET, it means you are trying to return some data based upon the GET request. You just have to make sure that whatever actions you are implementing must be prefixed with the right request type (GET, POST, PUT, and DELETE).
    Note: The method name need not be Get () or Post () etc. However it does not limit to prefixing the request types. You can still implement the actions with different naming but you have to make sure to use the suitable action filters [Http Get], [Post], [Put], [Delete].
    Background
    This article is just a start of a beginner article for Web API. A basic understanding of MVC is sufficient to understand and implement asp.NET Web API.
     B.原文的翻译
  1. 上一篇:JDBC-Spring框架英文文献和中文翻译
  2. 下一篇:JSP技术的发展历程英文文献和中文翻译
  1. Java技术的Web应用设计模型...

  2. ASP.NET技术先进的控件编程...

  3. Web2.0的网络广告模式英文文献和中文翻译

  4. 从经典ASP到ASP.NET英文文献和中文翻译

  5. ASP.NET技术英文文献及中文翻译

  6. ASP英文参考文献翻译

  7. ASP.NET概述英文文献和中文翻译

  8. 酸性水汽提装置总汽提塔设计+CAD图纸

  9. java+mysql车辆管理系统的设计+源代码

  10. 当代大学生慈善意识研究+文献综述

  11. 杂拟谷盗体内共生菌沃尔...

  12. 电站锅炉暖风器设计任务书

  13. 大众媒体对公共政策制定的影响

  14. 中考体育项目与体育教学合理结合的研究

  15. 乳业同业并购式全产业链...

  16. 河岸冲刷和泥沙淤积的监测国内外研究现状

  17. 十二层带中心支撑钢结构...

  

About

751论文网手机版...

主页:http://www.751com.cn

关闭返回