I'm trying to figure out how to send IP in GET request. I want to call GET request like : /api/endpoint/12.12.12.12
. I tried to encode it but HttpUtility.UrlEncode
won't encode dots for IP alone. When I try use %2E
as dot then IIS throws 404.11 - The request filtering module is configured to deny a request that contains a double escape sequence.
. How to I make it the right way?
Asked
Active
Viewed 125 times
1

Meroz
- 859
- 2
- 8
- 28
-
Why do you want to encode the IP anyway? Why not just send it as it is? – erikvimz Oct 20 '17 at 13:24
-
what is the problem if you just send the IP as is? it does not contain any special character which need to be escaped – Gusman Oct 20 '17 at 13:24
-
BTW what happens if you send it *as is* with dots? – Matías Fidemraizer Oct 20 '17 at 13:24
-
send it as string – Rahul Oct 20 '17 at 13:24
-
1@Gusman If you use periods, some servers (like IIS) can get confused and think it's a static file unless you modify the web.config – DavidG Oct 20 '17 at 13:25
-
@DavidG Then replace `.` with `-` ? – erikvimz Oct 20 '17 at 13:26
-
@ErikKralj Well that's why OP is asking how to encode it... – DavidG Oct 20 '17 at 13:26
-
Possible duplicate of [Dots in URL causes 404 with ASP.NET mvc and IIS](https://stackoverflow.com/questions/11728846/dots-in-url-causes-404-with-asp-net-mvc-and-iis) – Rahul Oct 20 '17 at 13:28
-
@Meroz There is no need to encode the IP. Send it as is or replace `.` with something else. If you try running `encodeURIComponent('12.12.12.12')` you will see the result is still `'12.12.12.12'` – erikvimz Oct 20 '17 at 13:28
-
If you know the IP address is IPv4, then you can use the `Address` property and pass the IP around as a `long`. Otherwise the `GetAddressBytes` method and send those as comma separated. There's a million ways to do it. – DavidG Oct 20 '17 at 13:28
-
I tried already replacing "." with "-" but wonder if there's another, proper solution – Meroz Oct 20 '17 at 14:18
3 Answers
1
Try to encode it in base 64. You can find how to do it here
/api/endpoint/MTIuMTIuMTIuMTI=

Tomasz Maj
- 1,541
- 15
- 15
0
You could just do a string replace.
"12.12.12.12".Replace(".","%2E");

Renato Fontes
- 68
- 7
-
IIS see it as secority issue and gives me `404.11 - The request filtering module is configured to deny a request that contains a double escape sequence.`. I wrote it in question. – Meroz Oct 20 '17 at 14:17
0
Add a slash at the end of the URL:
/api/endpoint/12.12.12.12/
this should work

owairc
- 1,890
- 1
- 10
- 9
-
My IIS configuration won't allow it. It recognize it as file as @DavidG wrote – Meroz Oct 20 '17 at 14:16