Web API Local Testing

Source: Internet
Author: User

"The simplest, I small white, big God do not spray"

One: Create Web API service side

① creating a Web API Project

② adds the following paragraphs to the Web. config for this API project:

<customHeaders>
<add name= "Access-control-allow-origin" value= "*"/>
<add name= "Access-control-allow-methods" value= "GET, POST, PUT, DELETE, OPTIONS"/>
<add name= "Access-control-allow-headers" value= "Content-type,x-requested-with"/>
<add name= "Access-control-request-methods" value= "GET, POST, PUT, DELETE, OPTIONS"/>
</customHeaders>

Under

③ Create an empty API controller under:

④ because only tests, create simple as:

The above Web API-side creation for testing is complete

Two: Create a Web MVC client

① solution creates an empty MVC:

② also creates an empty MVC controller:

③ Add the following code to index.cshtml

Completion of the above MVC client

Three: Run the test

① Run tests need to maintain the operational state of the API server:

② after running is this no tube

③ manually entering the MVC client address

Run successfully

Web API Local Testing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.