In the previous article, I used ASP. NET adds a Help Page. In this article, I plan to add a test tool to the page so that we can directly test the API during development, which is very beneficial to development!
You can also read this article to add Test Tool: http://blogs.msdn.com/ B /yaohuang1/archive/2012/12/02/adding-a-simple-test-client-to-asp-net-web-api-help-page.aspx
Click Install.
The following files will be added to your project:
Scripts \ WebApiTestClient. js
- Areas \ HelpPage \ TestClient.css
- Areas \ HelpPage \ Views \ Help \ DisplayTemplates \ TestClientDialogs. cshtml
- Areas \ HelpPage \ Views \ Help \ DisplayTemplates \ TestClientReferences. cshtml
At this time, we need to modify this file:
<link type= href= rel= /> <div id= => <section => <div => <p> @Html.ActionLink(, </p> </div> </section> <section => </section> </div> @Html.DisplayForModel( <link type= href= rel=/> @Html.DisplayForModel( }
Yes, that's simple.
You need to be sure that your package must be on this or above:
JQuery 1.7.1
- JQuery. UI. Combined 1.8.20
- Knockoutjs 2.1.0
3. Check the page.
Find any API on the Help page and click to view it. You will find a Test API button in the lower right corner. Click the Test tool we want.
The returned result is correct.
Remember this and learn later.