How to use wcf service in MVC 5.

In this article, I m explain How to use wcf service in MVC 5.

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

Now Continue with previous post.

Create new project, Right Click on Solution Explorer and add new project.

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


ASP.NET WEB APPLICATION

Select Empty MVC Template.


ASP.NET MVC WEB APPLICATION

Your MVC project add in solution explorer.

Now first copy wcf service url.(Please first check previous post here)


ADD SERVICE REFERENCE


Now EmployeeService service references add in your WebApplication.

SERVICE REFERENCE IN ECF

Now right click on Employee service and Click on Configure Service Reference. 

CONFIGURE SERVICE REFERENCE

Now uncheck Reuse type in referenced assemblies and click ok.

CONFIGURE SERVICE REFERENCE


Add New Controller in MVC application.
CONTROLLER IN MVC

Now add following code in Index action.


ADD VIEW IN MVC
Right click on Action method and Add View.

Now Select Template List and Model class.


ADD VIEW IN MVC

Your View code look like this.


VIEW IN MVC


Now Run Application(Ctrl + F5).


WCF APPLICATION

Enjoy..!

Post a Comment