将简单的 WCF 服务部署到 Web 服务器
在 IIS 7.0 中创建了一个新目录 XYZ。将 web.config、Service.cs 和 Service.svc 复制到该目录。现在浏览 http://www.mydomain.com/XYZ/Service.svc 我我收到“500 内部服务器错误”。
这是 web.cofig 文件。
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
我认为配置文件可能存在一些问题,但该服务在本地计算机上运行得很好。
Created a new Directory XYZ in IIS 7.0. Copied the web.config, Service.cs and Service.svc to the directory. Now on browsing http://www.mydomain.com/XYZ/Service.svc I am getting a '500 internal server error'.
Here is the web.cofig file.
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
I am thinking there might be some problem with the config file, but the service runs pretty ok on local machine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您必须使用 dll 文件而不是代码文件。编译代码并将dll放入“bin”文件夹中。
其次,您没有将端点添加到 web.cofnig 中:
并检查 svc 文件,其中的服务名称应与配置文件中的服务名称相对应。如果服务有一行
,则 svc 文件应为At first, you must use dll-file instead of code file. Compile code and put dll into the "bin" folder.
At second, you didn't add endpoints into web.cofnig:
And check svc file, a service name inside it should correspond to a service name inside a config file. If a service has a line
<service name="SiteService">
, svc file should be