Web API 1:
Required Environment (VS2010/.NET4.0/MVC4)
Http://www.asp.net/web-api/overview/creating-web-apis/creating-a-web-api-that-supports-crud-operations
Web API 2:
Required Environment (VS2012OR2013/.NET4.5/MVC5)
Http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api
The problems and areas to be aware of in the process of writing code with an instance in one step:
1.Web API 2 needs to update MICROSOFT.ASPNET.WEBAPI through NuGet, otherwise the new interfaces such as Ihttpactionresult are not recognized.
Pm> install-package Microsoft.AspNet.WebApi can be.
2. The data formats returned by default in different browsers are variable.
IE and FF send different request headers for the Accept header, so the Web API responds with a different content type.
such as direct access to HTTP://LOCALHOST:8382/API/PRODUCTS/1
(1) Firefox returns XML
<product><category>groceries</category><id>1</id><name>tomato Soup</Name ><Price>1</Price></Product>
Accept Header: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
(2) IE returns the JSON, which pops up the "File Download" dialog box.
{"Id": 1, "Name": "Tomato Soup", "Category": "Groceries", "Price": 1.0}
Accept header: Image/gif, Image/jpeg, Image/pjpeg, Image/pjpeg, Application/x-shockwave-flash, application/ X-ms-application, APPLICATION/X-MS-XBAP, Application/vnd.ms-xpsdocument, Application/xaml+xml, application/ Vnd.ms-excel, Application/vnd.ms-powerpoint, Application/msword, */*
If you need the unified Web API to return only JSON, you can refer to:
(1) http://www.cnblogs.com/acles/archive/2013/06/21/3147667.html
(2) http://www.strathweb.com/2013/06/supporting-only-json-in-asp-net-web-api-the-right-way/
(3) http://www.strathweb.com/2012/07/everything-you-want-to-know-about-asp-net-web-api-content-negotation/
3. LocalHost is not recognized under IE when using fiddler
It needs to be accessed via http://localhost.:8382/api/products, which is followed by a "decimal point" behind localhost.