2011-03-06 68 views
1

嗯,這看起來很傻,所以我覺得很傻。我有一個具有字符串參數的Odata服務的自定義操作。它正常工作時,該字符串不包含特殊字符,但只要我包括[']字符,我得到:'Odata Url字符串參數中的字符

<?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)); 

我'已經嘗試編碼像這樣[&'](xml編碼),並像這樣[%27](網址編碼),事情仍然爆炸。

+1

可能重複[如何轉義單引號用於OData查詢?](http://stackoverflow.com/questions/3979367/how-to-escape-a-single-quote-tobe -used-od-odata-query) – 2011-03-06 06:43:05

+0

是的,抱歉沒有找到這個問題,它似乎是同樣的事情。 – 2011-03-07 05:20:12

回答