Using a backslash (\) in a REST WCF URL

后端 未结 1 759
野性不改
野性不改 2020-12-20 03:47

I am building a REST service on WCF, and one of the methods I am writing is GetProfile, which will return the profile for a given username. The username will include the use

相关标签:
1条回答
  • 2020-12-20 04:18

    I suspect that they are simply not allowed in that part of the url. They are fine in the query string as long as they are encoded. As a general rule i wouldn't put anything in the path part of the url that is invalid in filename (i.e. ?).

    Perhaps you could use a different character to deliminate th domain from the username.

    You could also seperate the username into domainname and username and use the normal path deliminator '/'. I'm not familar with the this enough to know if this is how you do it for sure, but this would be my best guess.

    [OperationContract]
    [WebGet(UriTemplate = "/{domainName}/{username}", ResponseFormat = WebMessageFormat.Xml)]
    IRestResponse GetProfile(String domainName, String username);
    
    0 讨论(0)
提交回复
热议问题