These URLs were found today when dealing with 500 errors in Google Webmaster:
http://www.cnblogs.com/Garnai/tag/3D%3F%96%CA/http://www.cnblogs.com/henryfan/tag/%3F%3F%3F%90%B6%90%AC%3F%8C% 8f/http://www.cnblogs.com/zhangpengshou/tag/%3f%96%da%3f%97%9d%94v%8fc%3f/http://www.cnblogs.com/henryfan/tag/ %3f%3f%3f%90%b6%90%ac%3f%8c%8f/...
These URLs not only appear with a 500 error, but do not display custom errors, only the default error page for asp:
The specific error message that is logged in the server log is:
[ArgumentOutOfRangeException: In a multi-byte target code page, there are no characters that this Unicode character can map to. (Exception from hresult:0x80070459)]System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal (Int32 errorCode, IntPtr errorinfo) +0 System.Runtime.InteropServices.Marshal.ThrowExceptionForHR (Int32 errorCode) +13563503 System.Web.Hosting.IIS7WorkerRequest.GetServerVariableInternal (String name) +50 System.Web.Hosting.IIS7WorkerRequest.ReadRequestHeaders (+144) System.Web.Hosting.IIS7WorkerRequest.GetKnownRequestHeader (Int32 index) +109 System.Web.HttpWorkerRequest.HasEntityBody () +27 System.Web.HttpRequest.GetEncodingFromHeaders () +126 System.Web.HttpRequest.get_ContentEncoding () +162 System.Web.HttpRequest.get_QueryStringEncoding () +10 System.Web.HttpRequest.get_QueryStringText () +209 System.Web.HttpRequest.ValidateInputIfRequiredByConfig () +87 System.Web.PipelineStepManager.ValidateHelper (HttpContext context) +55
The corresponding English error message is:
No mapping for the Unicode character exists in the target Multi-Byte code page.
A rule has been observed from these faulty URLs: all contain the%3f code, and the corresponding characters are decoded.
From the code execution stack information System.Web.HttpRequest.get_QueryStringText () of the error message, you can see that the error occurred while reading the query string from the URL.
But there is no query string in the wrong URL ...
Then suddenly thought, ASP. NET is urldecode first, then Get_querystringtext ().
For example, the URL that is obtained after http://www.cnblogs.com/Garnai/tag/3D%3F%96%CA/ is UrlDecode is:
Http://www.cnblogs.com/Garnai/tag/3D? Canes/
See no, a question mark appears and becomes a URL with a query string. So, ASP. NET reads the character after the question mark as key, because key does not support Chinese, it throws "in the multi-byte target code page, there is no character that this Unicode character can map to". If ASP. Get_querystringtext (), then UrlDecode does not trigger the problem, but ASP.
So how do you solve this problem?
Although the problem is in ASP. NET, we can not change the ASP.
Since this is a problem with the ASP, we have no choice but to intercept such URL requests before ASP. The simplest tool for such interception is the URL of IIS Rewrite module.
According to our application scenario, add a rule in rewriterules.config--if a question mark appears after/tag/in the URL and returns 404 directly, the rule is defined as follows:
<Rulename= "Block_invalid_tag_url"stopprocessing= "true"> <MatchURL= "^[^/]+/tag/.*?\?". *$" /> <Actiontype= "Customresponse"StatusCode= "404"Statusreason= "The request URL is invalid"statusdescription= "The request URL is invalid" /></Rule>
Then I took care of the problem and wrote this blog post.
Resolves "in a multi-byte target code page, there are no characters that this Unicode character can map to"