Why is the comma URL encoded?

前端 未结 4 1984
暖寄归人
暖寄归人 2020-12-09 08:14

When debugging in ASP.NET MVC, I don\'t see a difference between:

http://mysite.com?q=hi,bye

and

http://mysite.com?q=hi%2Cb         


        
4条回答
  •  情深已故
    2020-12-09 08:52

    This is really browser dependent. The browser takes the HTML form and decides how to build the URL based on the form's inputs.

    If you're using a really old (or poorly programmed) browser, it may not encode the comma. If you adhere to RFC standards, it really should be encoded.

    If you want to prevent the comma from being encoded for all browsers, you would have to use JavaScript and build the URL yourself.

    
    

    In any case, it shouldn't matter, because you should be decoding the querystring parameters anyway, and the result will be the same.

提交回复
热议问题