How to Use WCF Service in MVC 5

In this article, I am explain how to use a WCF service in MVC 5.

In my previous article I explained How to Create WCF Service in Visual Studio 2013.

Now to continue from that article we will create a new project.

Right-click on Solution Explorer and add a new project.

Select ASP.NET Web Application with .NET Framework 4.5.

Web Application

Select Empty MVC Template.

MVC Template

Your MVC project will be added to the Solution Explorer.

Now first copy the WCF service URL. (Please first check previous article here.)

copy wcf service url

Now an EmployeeService service reference is added to your WebApplication.

WebApplication

Now right-click on the Employee service and click on Configure Service Reference.

Configure Service Reference

Now uncheck Reuse type in referenced assemblies and click OK.

 referenced assemblies

Add a New Controller to the MVC application.

Controller

Now add the following code to the Index action.

code

Right-click on the Action method and Add View.

Add View

Now Select Template List and Model class.

Model class

Your View code will look like this.

View code look

Now run the application (Ctrl + F5).

Run Application