【问题标题】:Resource not found for the segment 'x'未找到段“x”的资源
【发布时间】:2012-01-04 18:28:13
【问题描述】:

我收到此错误:找不到片段“GetTest”的资源。

代码是这样的:

    [WebGet]
    public IQueryable<string> GetTest()
    {
        var tmp = new List<string>();
        return tmp.AsQueryable();
    }

有什么想法吗?

【问题讨论】:

  • 我们可以看看您的客户端实现吗?你怎么称呼它?有没有可能返回null?

标签: c# .net wcf


【解决方案1】:

在查找不存在的主键时引发“未找到该段的资源”

用 try-catch 试试

try  
{  
   var tmp = new List<string>();
   return tmp.AsQueryable();
}  
catch( DataServiceQueryException ex )  
{  
   return null;
}  

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-22
    • 2017-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-30
    • 2013-06-22
    相关资源
    最近更新 更多