c# - 相对 URI 不支持此操作,浏览 SVC 服务时出错

标签 c# wcf web-services svc

浏览网站的 svc-service 时出现以下错误(在它所在的服务器上浏览)。该网站使用IIS7。

This operation is not supported for a relative URI.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: This operation is not supported for a relative URI.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidOperationException: This operation is not supported for a relative URI.]
   System.Uri.get_Scheme() +8045854
   System.ServiceModel.HostingManager.FilterBaseAddressList(Uri[] baseAddresses, Uri[] prefixFilters) +142
   System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +598
   System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +50
   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +1172

[ServiceActivationException: The service '/Templates/eDemokrati/Services/eDemokratiService.svc' cannot be activated due to an exception during compilation.  The exception message is: This operation is not supported for a relative URI..]
   System.Runtime.AsyncResult.End(IAsyncResult result) +900192
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +192830
   System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +107


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272 

服务链接:Link

网站的一些 web.config:

<system.serviceModel>
  <serviceHostingEnvironment>
        <baseAddressPrefixFilters>
            <add prefix="http://www.roros.kommune.no/"/>
            <add prefix="www.roros.kommune.no/"/>
            <add prefix="item"/>
            <add prefix="http://www.roros.kommune.no/templates/eDemokrati/Services/"/>
            <add prefix="www.roros.kommune.no/templates/eDemokrati/Services/"/>

        </baseAddressPrefixFilters>
    </serviceHostingEnvironment>

错误是什么引起的,我该如何解决?

最佳答案

如异常消息所示,不允许使用相对 URI。尝试删除 prefix="item" 并将它们全部设为绝对 URI。

关于c# - 相对 URI 不支持此操作,浏览 SVC 服务时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14523076/

相关文章:

c# - <%# 的默认值(绑定(bind)或评估)

asp.net - 从 ASP.NET 调用 WCF 服务器

javascript - 在 D3 Javascript 可视化中使用 JSON 数据

javascript - 如何从 Spring MVC Controller 将数据传递到浏览器 JavaScript

c# - Visual Studio 2013+ 数据库项目 - 部分架构/导入部分数据库项目

c# - 在 Xamarin Forms 中将视频文件转换为音频文件

c# - 使用自定义比较函数断言

WCF 集合序列化,IList 还是 List?有关系吗?

asp.net - 我可以将 ASP.NET Web 服务升级到 WCF 并仍然从 ASP.NET 1.1 调用它吗?

java - 创建测试自动化套件即服务的最佳方法是什么