MVC applications use WCF Service

Source: Internet
Author: User
Original: MVC application uses WCF Service

The previous insus.net has demonstrated that the MVC application uses a Web service, and this article insus.net wants to continue the demo service, but it is a WCF service.

The two implementations are somewhat different.

Under the Services directory, create a calculator.svc service. After a successful creation, it generates an interface and a file for the SVC:



In Calculator.svc, it is the interface above the implementation, and all four methods are implemented:

After the WCF service is created, it can be viewed as normal:

The following is a reference to a WCF Service for an MVC application:


When you are done quoting, you will see the following information in Web. config:

Locate and open ExerciseController.cs, create the View ActionResult Wcfservicedemo () and Contentresult Getcalcresult ():

Create a wcfservicedemo.cshtml view under Views\exercise, in the following three steps:


The third step is the jquery code:


Live Demo:

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.