Asp.net WEB API:当URL以<结尾时,如何处理400错误的请求错误 [英] Asp.net WEB API : how to handle 400 bad request error when URL ends with <
本文介绍了Asp.net WEB API:当URL以<结尾时,如何处理400错误的请求错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试处理我的自定义错误页面的所有HTTP错误,但我发现当有一个<在url的末尾。
示例:http:// localhost /<
响应是:错误请求 - 无效URL HTTP错误400.请求URL无效。
我想返回特定的错误消息这个场景。
任何人都可以告诉我们如何解决这个问题。
提前感谢你们所有人
我尝试了什么:
我试图在google中搜索无法为此找到正确的解决方案
I am trying to handle all HTTP errors to my custom error pages, but I find that when there is a < at the end of url.
Example: http://localhost/<
Response is: Bad Request - Invalid URL HTTP Error 400. The request URL is invalid.
I want to return specific error message in this scenario.
Can anyone tell how to fix this.
Thanking You all in advance
What I have tried:
I tried to search in google not able to find the correct solution for this
推荐答案
可能是因为没有解决方案。在请求到达IIS之前,这些请求在内核级别被阻止:
正确处理IIS请求的百分比登录网址(/%) [ ^ ]
IIS如何阻止URL中的字符 [ ^ ]
使用IIS URL中的'%''和':'等特殊字符 [ ^ ]
您可能能够通过更改注册表将请求传递到IIS,但这会使您的服务器更容易受到攻击:
Wackiness中的实验:允许ASP.NET / IIS请求URL中的百分比,尖括号和其他顽皮的东西 - Scott Hanselman [ ^ ]
Probably because there isn't a solution. Those requests are blocked at the kernel level, before the request even reaches IIS:
Properly handle IIS request with percent sign in url (/%)[^]
How IIS blocks characters in URLs[^]
Use of special characters like '%' '.' and ':' in an IIS URL[^]
You might be able to get the request through to IIS by changing the registry, but this will leave your server more vulnerable to attack:
Experiments in Wackiness: Allowing percents, angle-brackets, and other naughty things in the ASP.NET/IIS Request URL - Scott Hanselman[^]
这篇关于Asp.net WEB API:当URL以<结尾时,如何处理400错误的请求错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文