• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

cynchanpin

  • 博客园
  • 联系
  • 订阅
  • 管理

View Post

应用程序中的server错误,没有名称为“ServiceBehavior”的服务行为

应用程序中的server错误,没有名称为“ServiceBehavior”的服务行为

        今天在阅读“创建和使用Web服务”的相关内容,在浏览器中查看Service.svc文件时遇到错误:应用程序中的server错误,没有名称为“ServiceBehavior”的服务行为。


        查看源码:
<?

xml version="1.0"?

> <configuration> <connectionStrings> <add name="NorthwindConnectionString" connectionString="Data Source=.;Initial Catalog=Northwind;User ID=sa;Password=123" providerName="System.Data.SqlClient"/> </connectionStrings> <system.web> <compilation debug="true" targetFramework="4.0"> <assemblies> <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies></compilation> </system.web> <system.serviceModel> <services> <service name="ProductsService" behaviorConfiguration="ServiceBehavior"> <!--Service Endpoints--> <endpoint address="" binding="wsHttpBinding" contract="IProductsService"/> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> </service> </services> <behaviors> <serviceBehaviors> <behavior> <!-- 为避免泄漏元数据信息,请在部署前将下面值设置为 false 并删除上面的元数据终结点 --> <serviceMetadata httpGetEnabled="true"/> <!-- 要接收故障异常具体信息以进行调试。请将下面值设置为 true。在部署前设置为 false 以避免泄漏异常信息--> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> </configuration>

        细致研读代码。原来须要在<behavior>节点加入属性:name="ServiceBehavior"。改动完毕后。在浏览器中查看。得到正确的Web服务。



posted on 2017-05-13 12:51  cynchanpin  阅读(934)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3