gpt4 book ai didi

带有加号的 c# URL 未通过自定义 HttpModule 运行

转载 作者:太空宇宙 更新时间:2023-11-03 19:14:02 24 4
gpt4 key购买 nike

我有一个自定义 HttpModule 来重定向来自网站旧版本的遗留 URL,它根据重定向数据库表检查传入的请求 URL。

但是,当传入请求 URL 包含加号 (+) 时,该请求不会通过 HttpModule - 它按预期的标准 URL 工作。

例如,这些 URL 有效:

http://www.example.com/sample-url
http://www.example.com/sample url
http://www.example.com/sample%20url

这些不会:

http://www.example.com/sample+url
http://www.example.com/sample%2Burl

这是我的模块声明:

<add name="LegacyUrlHttpModule" type="Web.LegacyUrlHttpModule, Framework.Web" preCondition="managedHandler" />

我是不是漏掉了什么设置?

最佳答案

Scott Hanselmann 写了一个 nice blog post解释如何在 url 的路径部分启用所有类型的废话符号。

他的结论如下:

After ALL this effort to get crazy stuff in the Request Path, it's worth mentioning that simply keeping the values as a part of the Query String (remember WAY back at the beginning of this post?) is easier, cleaner, more flexible, and more secure.

所以基本上如果你在 url 中有这样的字符,这些字符应该作为查询字符串参数传递,而不是试图在路径部分传递它们。

关于带有加号的 c# URL 未通过自定义 HttpModule 运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18470524/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com