2

I have this request https://192.xxx.x.x/%3cscript%3e_q_q=%27%29%28%27%3c/script%3e

After making it on my server, I have this: enter image description here

How can I display a more friendly message instead? Note: I have my asp.net c# application hosted here on: https://192.xxx.x.x/Myapp

Any suggestion would be appreciated

osagie
  • 251
  • 2
  • 6
  • 15
  • Are you looking to serve up a more friendly error page for yourself? Or show something like an "oops, error has occurred page for users"? – reZach Jul 13 '18 at 17:01
  • 2
    I am not sure you have to censor your IP, a _great majority_ of us have the exact same local address(es) haha – maccettura Jul 13 '18 at 17:02
  • Do you want to make the error not happen anymore? Or just have a better looking page when it breaks (i.e not fixing the problem) – maccettura Jul 13 '18 at 17:03
  • @Zac something like "Ops, error has occurred" would be ok. – osagie Jul 14 '18 at 15:43

1 Answers1

1

You could first disable the built-in ASP.NET middleware that throws this HTTPException and then add your own ASP.NET or ASP.NET Core middleware that handles inspecting the request path for dangerous characters and performing a custom action (like throwing a different exception, redirecting to a custom error URL, etc).

Matthew Steven Monkan
  • 8,170
  • 4
  • 53
  • 71