The last two articles described how to create Basic Windows Communication Foundation Service and Basic Windows Communication Foundation Client, this article will describle how to host WCF service in IIS. Download the code of WCF service from Basic Windows Communication Foundation Service
Step 1: Add new WCF Service Web Site, name the new service as EmpService
Step 2: Delete IService.cs and Service.cs from App_Code, it is not required.
Step 3: Add reference of Employee Service, EmployeeService.dll will be added in the bin
Step 4: Change the name of Service.svc to EmployeeService.svc, open EmployeeService.svc. It will contain
<%@ ServiceHost Language="C#" Debug="true" Service="Service" CodeBehind="~/App_Code/Service.cs" %>Step 5: Right click on Web.Config and Edit WCF configuration, change EndPoint contract IService to EmployeeService.IEmployeeService
Change the Service="Service" to Service="EmployeeService.EmployeeService" and remove CodeBehind="~/App_Code/Service.cs" as there is no codebehind file in App_Code
Now EmployeeService,svc should contain below line
<%@ ServiceHost Language="C#" Debug="true" Service="EmployeeService.EmployeeService" %>
Step 6: Change the name of service from Service to EmployeeService.EmployeeService
Now if you open Web.Config file, there will be service with name EployeeService.EmployeeService and endpoint with contract EmployeeService.IEmployeeService
Step 7: Right Click on EmployeeService.svc and select View in Browser. Employeeservice Service will come up in the browser.
Step 8: Follow below steps to host in IIS
1. Open IIS, Right click on Web Site(Default Web Site or any other website) and select Add Virtual Directory.
2. Provide Alias and Physical Path of EmpService and Click ok.
3. We are done and ready to browse the EmployeeService.svc