locked
pound sign invalid in string RRS feed

  • Question

  •  

    Passing a # pound sign in string will cause invalid query request.

     

    string desc = "some c#";

    var q = ...AddQueryOption("desc", "'"+desc+"'");

    q.Execute(); // Bad Request - Error in query syntax.

     

    How to escape the # sign?  Thanks.

     

    Monday, October 13, 2008 5:43 AM

Answers

  • you can encode the data part of the URI using Uri.EscapeDataString Method

     

    Code Snippet

    string desc = "some c#";

    desc= Uri.EscapeDataString(desc);

    var q = ...AddQueryOption("desc", "'"+desc+"'");

    q.Execute();

     

     

    Monday, October 13, 2008 4:33 PM
    Moderator
  • Thanks Phani.

    Monday, October 13, 2008 6:01 PM

All replies

  • you can encode the data part of the URI using Uri.EscapeDataString Method

     

    Code Snippet

    string desc = "some c#";

    desc= Uri.EscapeDataString(desc);

    var q = ...AddQueryOption("desc", "'"+desc+"'");

    q.Execute();

     

     

    Monday, October 13, 2008 4:33 PM
    Moderator
  • Thanks Phani.

    Monday, October 13, 2008 6:01 PM