The Chinese characters are garbled during Intelligencia. UrlRewriter.
Due to business needs, some modules of the project have recently been modified to pseudo-static, and Intelligencia. UrlRewriter. dll components have been used.
Intelligencia. UrlRewriter. dll configuration on the Internet to explain a lot, here not to mention, (such as: http://www.cnblogs.com/naoguazi/p/URLReWriter.html)
This article mainly describes solutions to Garbled text when Url is passed.
1. At first, we used "cheap tricks" to solve the problem.
The idea is to encode Chinese characters when passing Chinese parameters through URLs. Jquery can use (encoding: encodeURIComponent (val); decoding: decodeURIComponent (val) for encoding and decoding. On the IISWeb server I use, the URL encoded parameter character is (% E8 % 9A % 82% E8 % 9A % 81% E7 % 94% B7 % E5 % AD % A9) an error is reported during transmission. Then I replace the percent sign (% E8 % 9A % 82% E8 % 9A % 81% E7 % 94% B7 % E5 % AD % A9 ") with a short underline ". replace (/%/gm ,'_')). Then, the string is transferred to the background and replaced, decoded, and then ......... The soldiers will block the attack, and the water will cover the earth. This is the case with cheap tricks. In the end, the Chinese parameters can be correctly passed into the background. Although this method solves the problem temporarily, it will leave a pain point for future friends.
2. Modify the source code and re-compile Intelligencia. UrlRewriter. dll. Make the component support passing Chinese parameters.
Find the source code on GitHub and download it. Https://github.com/OptimityAdvisors/Intelligencia.UrlRewriter)
Open the solution and insert the code into the RewriterEngine. cs file private string Reduce (RewriteContext context, StringReader reader) method.
result = string.Join("&", result.Split('&').Select(e => string.Join("=", e.Split('=').Select(o => HttpContext.Current.Server.UrlEncode(o)))));
After saving the compiled dll, it will support passing Chinese characters,
Note that parameters received in the background are decoded before use.
var str= HttpContext.Current.Server.UrlDecode(str);
Dll that supports Chinese parameters: Download