0

So I have a URL to my wcf service that looks like this:

http://dev.verse-master.com/api/VerseMasterService.svc/Search/bi/isaiah 34:16/0/60

My operation contract looks like this:

[OperationContract]
[WebGet(UriTemplate = "/Search/{translation}/{searchTerm}/{skip}/{take}", ResponseFormat = WebMessageFormat.Json)]
VerseMaster.BusinessLayer.DataObjects.ServerObjects.GetVersesSearchServerObject GetVersesBySearch(string translation, string searchTerm, string skip, string take);

I have tried from reading online to add this line to the web.config:

<httpRuntime requestPathInvalidCharacters="" requestValidationMode="4.0"/>

But I still get this error:

HTTP Error 400 - Bad Request.

Any ideas?

dbc
  • 104,963
  • 20
  • 228
  • 340
nbarger27
  • 9
  • 5
  • Maybe related (though apparently not duplicate) [Using a colon (:) in a url with ASP.NET/IIS](https://stackoverflow.com/q/667429/3744182). – dbc Jan 19 '23 at 18:19

1 Answers1

0

encode the url and it should be fine, just handle it when it returns. that'll help with the backslash as well which will cause equal amounts of problems as the :

eg

calling the service:

String encodedSearchTerm = Server.UrlEncode(searchTerm);
String UrlToCall = String.Format("{0}{1}{2}","http://dev.verse-master.com/api/VerseMasterService.svc/Search/bi/",encodedSearchTerm,"/0/60");

...etc...

then in your operation:

[WebGet(UriTemplate = "/Search/{translation}/{searchTerm}/{skip}/{take}", ResponseFormat = WebMessageFormat.Json)] 
VerseMaster.BusinessLayer.DataObjects.ServerObjects.GetVersesSearchServerObject GetVersesBySearch(string translation, string searchTerm, string skip, string take){
...etc...
String DecodedSearchTerm= Server.UrlDecode(searchTerm);
...etc...
}

rememeber need to import System.Web

Chris
  • 2,471
  • 25
  • 36