asp.net - 我可以在 URL 中使用逗号吗?

标签 asp.net iis url url-rewriting

我通常使用 URL 重写将内容 ID 传递到我的网站,因此这

 Foo.1.aspx 

重写为

 Foo.aspx?id=1

对于特定应用程序,我需要将多个 ID 传递到单个页面,因此我重写了一些内容来接受这一点:

 Foo.1,2,3,4,5.aspx

这在 Cassini(Visual Studio 的内置临时 Web 服务器)中运行良好,但当我在运行 IIS 的实时服务器上尝试它时,却显示“Internet Explorer 无法显示网页”。这是 IIS 的限制吗?我应该只使用破折号或下划线而不是逗号吗?

最佳答案

据我所知,URL 的文件名部分允许使用逗号,但在域*中是保留字符。

您使用的是哪个版本的 IE?我遇到过 IE5.5 在逗号上截断 URL 的奇怪报告( link here ,但在 IE7 中测试了带有逗号的 URL,似乎没问题,所以如果有 IE bug,似乎不会继续出现 - 可能是 IIS 问题吗?

我想知道页面错误是否是由于 mod_rewrite 规则失败所致 - 您能否发布匹配多个 id 的规则并将它们传递到您的 Foo.aspx ?有没有可能它只匹配 Foo.N,N,并且因更多逗号而失败?

<小时/> *来自URI RFC :

2.2. Reserved Characters

Many URI include components consisting of or delimited by, certain special characters. These characters are called "reserved", since their usage within the URI component is limited to their reserved purpose. If the data for a URI component would conflict with the reserved purpose, then the conflicting data must be escaped before forming the URI.

 reserved    = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
                "$" | ","

The "reserved" syntax class above refers to those characters that are allowed within a URI, but which may not be allowed within a particular component of the generic URI syntax

关于asp.net - 我可以在 URL 中使用逗号吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/198606/

相关文章:

javascript - "Don' t 允许访问剪贴板 "doesn' t 允许在文本框中输入任何内容

asp.net - 当 HttpModule 中抛出异常时 ASP.NET MVC 中的自定义错误消息

iis - 通过删除多个RSA文件而不接触IIS文件来清理我的MachineKeys文件夹

python - 奇怪的网站编码。是否有可能使用 python 获取它?

c# - Web API 2 - 错误 : "No type was found that matches the controller named ' resize'.“

javascript - 为什么 JQuery 对话框在最大化模式下稍微超出主窗口

iis - 使用一个日志记录应用程序 block 日志文件的多个进程

apache - htaccess 规则 (mod_rewrite) 转换为 web.config 规则

javascript - 资源的 url 路径

node.js - 忽略 http 方法和路径的 API 的缺点