如何从Visual Studio将Web服务发布到IIS? [英] How to publish a Web Service from Visual Studio into IIS?

查看:880
本文介绍了如何从Visual Studio将Web服务发布到IIS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#中编写了一个WCF Web服务。我最初是自托管它,然后决定在我的PC上本地运行的IIS上托管它。虽然服务正在运行,但我不了解部署过程的几个方面:

I have written a WCF web service in C#. I had originally self-hosted it and then decided to host it on IIS running locally on my PC. While the service is working, there are several aspects of the deployment process that I don't understand:

首先,在IIS中托管时此服务的URL不对应我在web.config中指定的内容。我在那里指定了 http:// localhost:8000 / MyServices / OrderService ,这是在我自我托管。现在我已部署到IIS,URL已变为 http:// localhost / MyServices / OrderService 。为什么没有从我的配置文件中提取URL?

Firstly, the URL of this service when hosted in IIS does not correspond to what I specified in my web.config. I had specified "http://localhost:8000/MyServices/OrderService" there and this was used when I self-hosted. Now that I've deployed to IIS, the URL has become "http://localhost/MyServices/OrderService". Why is the URL not picked up from my config file?

其次,为了托管Web服务,我在IIS中创建了一个新的网站(除了现有的'默认网站')。我将物理路径设置为c:\inetpub\wwwroot(不知道这是否正确)并将其他参数保留为默认值。然后我将我的/ bin文件夹,我的.svc文件和我的web.config复制到此文件夹中。这相当于虚拟目录吗?

Secondly, to host the Web Service, I created a new web site within IIS (in addition to the existing 'Default Web Site'). I set the physical path to c:\inetpub\wwwroot (no idea if this is correct) and left the other parameters as default. I then copied my /bin folder, my .svc file and my web.config to this folder. Is this the equivalent of a 'Virtual Directory'?

最后,直到(在IIS中)我选择转换为应用程序时,该服务才起作用。为什么有必要选择转换为应用程序?

Finally, the service didn't work until (within IIS) I selected 'Convert to application'. Why is it necessary to select 'Convert to application'?

任何人都可以解释将Visual Studio中的简单Web服务发布到IIS中的正确步骤,或者指向我在一些好的文档,所以我可以理解这个过程?

Can anyone explain what the correct procedure is to publish a simple web service from Visual Studio into IIS, or point me at some good documentation so I can understand the process?

****编辑原始*****
花了更多时间研究这个,我找到了以下内容:

****EDIT TO ORIGINAL***** Having spent more time looking into this, I have found the following:


  • 当我在IIS中创建一个网站时,我给它一个c:\inetpub \\的物理目录\\ www.root .... etc

  • 如果我从Visual Studio中发布,它所做的就是复制所有必需的文件(比如/ bin目录,web.config和。 svc文件)进入网站的物理目录即 - c:\inetpub \ www.root ...

你可以执行手动复制到相同的影响。

You can perform the copy manually to the same affect.

  • Lastly, with regard to the URL of my service not corresponding to the baseAddress section of my web.config file, this has been answered on stackoverflow previously.

答案是在IIS上托管时完全忽略baseAddress。

The answer is that the baseAddress is completely ignored when hosting on IIS.

推荐答案

如果使用Visual Studio 2010,您可以右键单击该服务的项目,然后选择特性。然后选择 Web 选项卡。在服务器部分下,您可以配置URL。还有一个用于创建虚拟目录的按钮。

If using Visual Studio 2010 you can right-click on the project for the service, and select properties. Then select the Web tab. Under the Servers section you can configure the URL. There is also a button to create the virtual directory.

这篇关于如何从Visual Studio将Web服务发布到IIS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆