How to encode a URL that provides a path to NancyFX

I have a module with the following GET API:

Get["/filesignature/{relativePath}"] = GetFileSignature;

And I'm trying to use WebClient.DownloadData with the following:

var myPath = @"mydirectory\myfile.exe";
client.DownloadData("filesignature/" + HttpUtility.UrlEncode(myPath));

I see that it is encoded before filesignature/mydirectory%5cmyfile.exe, so it looks right.

However, I return 404. I tried to do this in a browser, and this is the same. When I delete %5c, my breakpoint in the call is reached. Therefore, there seems to be a problem with backslash encoding.

Any tips?

+4
source share
2 answers

Therefore, I did not find the exact solution to my problem. But instead, I use the Query WebClient property and set the name / values ​​correctly. Then no encoding is required.

+1

. https://github.com/NancyFx/Nancy/issues/1280

, :

..

:

"foo/bar% 2fbaz" "foo/{bar}/baz", , "/" ( ).

(% 5c).

:

  • querystring
  • % ! URL, (yuk)
  • ...
+1

All Articles