It is a good choice to write a service using WCF and then use IIS as the host, but this may encounter some minor problems during actual deployment, as described below.
When debugging the local machine, there is no problem. Pay attention to the access address marked with a red pen in the figure.
However, after deploying it to a real server, we found that the metadata address is not the IP address we expected, but the host name.
In this way, if you directly use this metadata to generate a client to access the Web service, the host name cannot be properly accessed due to host name interpretation failure. You must manually specify the access address for the client.
What should I do if people are unhappy? After a lot of research, I finally found a solution to solve this problem by configuring IIS.
1. Enter the command "inetmgr" on the server to enable IIS configuration.
2. Right-click "default website" and select "properties" in the pop-up menu (assume that your web service is in the default website)
3. Select "advanced" in the "website ID" Area of the "website" tab ",
4. For example, select the entry "Default Value" and click "edit"
5. Enter "10.186.3.21" in "Host Header Value". This is the IP address of my host.
6. OK. It will be done!
Slow! You will find that the problem still exists and remains unchanged at all. What is the problem? I am so sleepy and hard to understand. In fact, to make the website take effect, I have to do one thing:
Click your web. config file to make the web service take effect again!
Web. config does not need to modify any content. You only need to enter a space in it, delete it, and save it. You can see it again:
It is quite difficult to find the answer to a small question.