【问题标题】:' character in string parameter of Odata Url' Odata Url 的字符串参数中的字符
【发布时间】:2011-03-06 14:42:53
【问题描述】:

嗯,这看起来很傻,所以我觉得很傻。我对具有字符串参数的 Odata 服务进行了自定义操作。当字符串不包含特殊字符时它可以正常工作,但是只要我包含 ['] 字符,我就会得到:

<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\r\n<error xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">\r\n  <code></code>\r\n  <message xml:lang=\"en-US\">Bad Request - Error in query syntax.</message>\r\n</error>

我正在使用以下代码调用服务:

new DataServiceContext(new Uri(svcUri)).Execute<string>(new Uri(relativeOperationUrl, UriKind.Relative));

我已经尝试过像这样的 [& apos;](xml 编码)和像这样的 [%27](url 编码)这样的编码,但事情仍然很糟糕。

【问题讨论】:

标签: wcf odata wcf-data-services


【解决方案1】:

尝试''(就像为 SQL 转义它);见How to escape a single quote to be used in an OData query?

【讨论】:

    猜你喜欢
    • 2015-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-22
    • 2015-03-30
    • 1970-01-01
    • 1970-01-01
    • 2010-10-14
    相关资源
    最近更新 更多