WCF # – 7 Create and host a WCF website in IIS
Hi Geeks,
In this article,we will cover following things
- Create a WCF Website
- Host a WCF website in IIS [Internet Information Services]
- Test the hosted site [To check whether it is correctly hosted or not]
NOTE :
To host the WCF website in IIS.Before , you must have created a WCFApplication/WCF Library containing your services.
1) Create a WCF Website
Step I : Take a new WCF Web Site
Click on the Website tab and you will see following window opened
Step II :
After creation of a WCF website go to the Solution explorer and add the Bin folder to it as shown in the figure below
Step III :
Right click on the bin folder created in above step and add the reference of the WCFApplication / WCFLibrary that you have already created.
Click on add reference you will see following window opened
Now your WCF website has been created and now we have to host it somewhere for using this website,so will host this site in to our IIS (Internet Information Services).
2) Host a WCF website
There are three steps in hosting a service in IIS:
Step I :
Create an ApplicationPool in IIS to store the service.
Go to an IIS
Right click on Application pool and add the new Application pool
Step II :
Create a WebSite in IIS to host the WCF service
The Physical path in the following figure is the path of the WCF Website folder that we have created above .
Hosting of the WCF Website has been completed here.
3) Test the Hosted Service
To Test whether site has been hosted correctly or not follow the following steps.
Step I :
Open the IIS.
Select the hosted website from the default web sites folder go to the right and say
Browse
then u will see the following WebPage opened with address as http://localhost/HostWCFService
Step II :
Now append the name of the .svc file in your WCF website to the address in the above address like follow
http://localhost/HostWCFService/Service.svc You will see the WebPage opened like follow.
After seeing this window with the main() method inside it,you can definitely say you have hosted the WCF Website correctly.
Thank you.