1

This is a C# question that might be related to Web, so, experts will advise.

I have a RestAPI to which I send requests (PUT, GET mainly). The base URL is, let's say, http://192.168.126.121:6677/base/rest/ini".

After this, for operation XYZ, I have to call for example http://192.168.126.121:6677/base/rest/ini/customer/acc/list

I noticed that my consoleapp runs normally even if I call http://192.168.126.121:6677/base/rest/ini/customer/acc//////list

(Notice the acc//////list part).

My question is dual:

  1. C# how can I forbid multiple / in my task and concatenate all the / into one? i.e. I get a URI from like http://192.168.126.121:6677/base/rest/ini/customer/acc//////list and I want to end up with http://192.168.126.121:6677/base/rest/ini/customer/acc/list

  2. for any experts in the field: is it normal that I get normal responses from the http://192.168.126.121:6677/base/rest/ini/customer/acc//////list url?

Thank you very much

Nick
  • 483
  • 1
  • 6
  • 15
  • 1
    Not familiar with this but [RewriteOptions](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.rewrite.rewriteoptions?view=aspnetcore-3.1) could help you to rewrite the url and redirect to the new one. [URL Rewriting Middleware in ASP.NET Core](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/url-rewriting?view=aspnetcore-3.1) – Kaj Feb 21 '20 at 15:38
  • Besides wanting clean URLs and clear expectations, why do you want to forbid this? – A Friend Feb 21 '20 at 15:38
  • @A Friend I am not sure if this is valid, hence I want to forbid it. I just read on the Rewrite option, thing is, I don't have access to the web server and I just found out that this works (the multiple slashes I mean) and I want to make a recommendation to forbid this, and at the same time make sure I am calling the proper URL. For the later (b) I found a solution using Uri object in C#. So concerning (a) I am still quite suspicious that this is to be allowed... – Nick Feb 22 '20 at 16:19

0 Answers0