MVC applications use Web Services (asmx)

Source: Internet
Author: User

This time, we will practice applying web service in the MVC application.
Create a directory Service in the MVC application to store Service. asmx.

This Service method, you can refer to the "Custom MVC Helper Extension Method" http://www.cnblogs.com/insus/p/3379485.html but not copy, need to modify:

Create an ExerciseController. cs and a view ActionResult under the Controllers directory:


After the Controller is created in MVC5, the related view directory is automatically created under the Views directory:



Create View:



In step #3, we write jquery code to obtain the data returned by the Web Server:



Real-time Demonstration:

The two Click events have the same processing logic and can be reconstructed into an extension method:

Related Article

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.