C# 如何在iis中注册web服务?

C# 如何在iis中注册web服务?,c#,web-services,iis,C#,Web Services,Iis,我有一个用c#制作的web服务,我想知道如何在IIS中注册它,以便从另一个应用程序中使用。我知道如何使用相同的解决方案,但情况不同。搜索internet时,我只找到了如何注册应用程序。web服务与IIS中的任何其他网站一样。只需将站点转换为应用程序并选择适当的.Net framework版本。web服务与IIS中的任何其他网站一样处理。只需将网站转换为应用程序并选择适当的.Net framework版本。为web服务设置网站后,需要在web.config中进行一些设置。我猜你可能会想念他们 将服

我有一个用c#制作的web服务,我想知道如何在IIS中注册它,以便从另一个应用程序中使用。我知道如何使用相同的解决方案,但情况不同。搜索internet时,我只找到了如何注册应用程序。

web服务与IIS中的任何其他网站一样。只需将站点转换为应用程序并选择适当的.Net framework版本。

web服务与IIS中的任何其他网站一样处理。只需将网站转换为应用程序并选择适当的.Net framework版本。

为web服务设置网站后,需要在web.config中进行一些设置。我猜你可能会想念他们

将服务添加到web.config,如下所示

<services>
  <service name="RestService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour">
    <endpoint address="" binding="webHttpBinding" contract="RestService.IRestServiceImpl" behaviorConfiguration="web">         
    </endpoint>
  </service>
</services>

还添加了服务行为和端点行为

<serviceBehaviors>
    <behavior name="ServiceBehaviour">
      <!-- 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>
  <endpointBehaviors>
    <behavior name="web">
      <webHttp/>
    </behavior>
  </endpointBehaviors>

为web服务设置网站后,需要在web.config中进行一些设置。我猜你可能会想念他们

将服务添加到web.config,如下所示

<services>
  <service name="RestService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour">
    <endpoint address="" binding="webHttpBinding" contract="RestService.IRestServiceImpl" behaviorConfiguration="web">         
    </endpoint>
  </service>
</services>

还添加了服务行为和端点行为

<serviceBehaviors>
    <behavior name="ServiceBehaviour">
      <!-- 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>
  <endpointBehaviors>
    <behavior name="web">
      <webHttp/>
    </behavior>
  </endpointBehaviors>


@BlaShadow-这是正确的答案。你的网站设置正确吗?您的web服务旁边还有其他html/aspx文件吗?@BlaShadow当它“不工作”时发生了什么?它是否抛出异常、返回404响应或服务器在巨大的蘑菇云中爆炸了?@BenRobinson是的,返回404响应,文件被删除了correctly@BlaShadow,是否正在指定完整路径?例如,您是否试图通过转到
http://foo.com
或转到
http://foo.com/MyService.asmx
?后者是正确的,假设您没有将
MyService.asmx
设置为默认文档。@JamesHill是本地文档。但是我指定了完整路径I相同的IIS返回我HTTP错误500.19-内部服务器错误:S@BlaShadow-这是正确答案。你的网站设置正确吗?您的web服务旁边还有其他html/aspx文件吗?@BlaShadow当它“不工作”时发生了什么?它是否抛出异常、返回404响应或服务器在巨大的蘑菇云中爆炸了?@BenRobinson是的,返回404响应,文件被删除了correctly@BlaShadow,是否正在指定完整路径?例如,您是否试图通过转到
http://foo.com
或转到
http://foo.com/MyService.asmx
?后者是正确的,假设您没有将
MyService.asmx
设置为默认文档。@JamesHill是本地文档。但是我指定了完整路径I相同的IIS返回给我HTTP错误500.19-内部服务器错误:扫描您发布您得到的错误。当您在IIS上发布web服务时,您是否可以使用IE浏览web服务。您是否可以提供一些有关web服务外观的示例代码,例如,它是WCF服务、旧web服务(asmx)或REST服务?您是否可以发布您遇到的错误。当您在IIS上发布web服务时,您是否可以使用IE浏览web服务。您是否可以提供一些有关web服务外观的示例代码,即WCF服务、旧web服务(asmx)或REST服务