C# 中的 request[] 无法正确解码 url

发布于 2024-07-14 13:34:20 字数 437 浏览 2 评论 0原文

我有一个像这样的对象:

public class adapterContext {
    public HttpRequest Request;
}
adapterContext ac = new adapterContext();
ac.Response = context.Response;

我将此对象传递给我的函数并使用 ac.Request[""] 来获取我的 url 变量。 然而,这在某种程度上并不能正确翻译国家/特殊字符。 当我使用 f.ex 作为 URL 的一部分时:prospectName=Tester+%e6+%f8+%e5

我得到“Tester ?? ? ”

从调试器中我得到: ac.Request["prospectName"][7] 65533 '�' char

有人知道我应该如何解决这个问题吗?

I have an object like this:

public class adapterContext {
    public HttpRequest Request;
}
adapterContext ac = new adapterContext();
ac.Response = context.Response;

I pass this object to my functions and use ac.Request[""] to get my url variables. However this somehow does not translate national/special characters correct. When I use f.ex this as part of the URL: prospectName=Tester+%e6+%f8+%e5

I get "Tester ? ? ?"

From the debugger I get: ac.Request["prospectName"][7] 65533 '�' char

Anyone have any idea how I should fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相权↑美人 2024-07-21 13:34:20

有一个很好的功能,您应该注意: HttpUtility .UrlDecode(字符串, 编码) ...
否则,您需要调整 web.config 中的全球化设置 (请求编码、响应编码...)

there's a nice function, you should take care of: HttpUtility.UrlDecode(string, Encoding) ...
otherwise you need to adjust the globalization setting in your web.config (requestEncoding, responseEncoding ...)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文