Sco*_*tes 26 forms asp.net-mvc urlencode query-string
在ASP.NET MVC中调试时,我没有看到以下区别:
http://mysite.com?q=hi,bye
Run Code Online (Sandbox Code Playgroud)
和
http://mysite.com?q=hi%2Cbye
Run Code Online (Sandbox Code Playgroud)
查询字符串参数"q"的值始终为"hi,bye".
那么为什么逗号编码?
我想做这样的事情/sf/answers/52647661/.
我有这样的形式:
<form method="GET" action="/Search">
<input type="hidden" name="q" value="hi,bye"/>
<input type="submit" value="ok"/>
</form>
Run Code Online (Sandbox Code Playgroud)
如何防止此值被编码?
Kyl*_*nes 19
URI规范RFC 3986指定URI路径组件不包含未编码的保留字符,逗号是保留字符之一.对于逗号之类的子逗号,将其保留为未编码的风险,该角色将被视为URI方案中的分隔符语法.百分比编码保证字符将作为数据传递.
我发现这个不需要 URL编码的字符列表:http://web.archive.org/web/20131212154213/http: //urldecoderonline.com/url-allowed-characters.htm
更新
自原始链接中断后,我使用archive.org从2013年12月的页面中获取以下文本
允许的URL字符列表
未保留 - 可以编码但不是必需的
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
a b c d e f g h i j k l m n o p q r s t u v w x y z
0 1 2 3 4 5 6 7 8 9 - _ . ~
Run Code Online (Sandbox Code Playgroud)
保留 - 有时必须编码
! * ' ( ) ; : @ & = + $ , / ? % # [ ]
Run Code Online (Sandbox Code Playgroud)