我可以只验证查询字符串中重复的变量名是否有效吗? [英] Can I just verify that repeated variable names in a query string are valid?

查看:130
本文介绍了我可以只验证查询字符串中重复的变量名是否有效吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对此不是100%肯定.我尝试在查询字符串中使用一组重复的变量,并且c#在控制器中可以很好地处理它.例如:

?x = 5&x = 7&x = 3

您将值发送到string [],就很好了.我在其他地方发布了一个问题(尝试此操作之前),并且似乎给人一种印象,即在查询字符串中重复相同的变量名称是无效的或非法的(如果我正确理解了它们的话).他说,由于他在使用PHP时遇到的困难无法很好地处理它(可能与您无法在PHP中声明变量有关).

有人可以澄清这是合法代码(查询字符串中重复的变量名)吗?

另外:我知道这似乎是一个奇怪的问题.如果它可以正常工作,那又何必质疑呢?我只想检查一下,以确保它不会在某些时候过时而引起问题.我找不到任何建议重复使用变量名是合法的-我看到有人这样做,但我无法澄清它的正确性.

I was not 100% sure about this. I tried using a set of repeated variables in the query string and c# handles it fine in the controller. For example:

?x=5&x=7&x=3

You send the values to a string[] and it is perfectly fine. I posted a question somewhere else (before trying this) and someone seems to be of the impression that repeating the same variable name in the query string is invalid or illegal (if I am understanding them correctly). He said that based on his difficulty with PHP not handling it very well (probably to do with you not being able to declare variables in PHP).

Could someone clarify that it is legal code (the repeated variable name in the query string)?

Additional: I know this may seem like a strange question to ask. If it is working then why bother questioning it? I just want to check to make sure that it is not something that will get deprecated down the road some time and cause problems. I cannot find any suggestion that it is legal to repeat variable names - I see people doing it but I cannot clarify the correctness of it.

推荐答案

行为明确的

看一下此链接:
http://stackoverflow.com/questions/1746507/authoritative-position- of-duplicate-http-get-query-keys [ ^ ]
It appears to not have a well defined behavior

Take a look at this link:
http://stackoverflow.com/questions/1746507/authoritative-position-of-duplicate-http-get-query-keys[^]


这篇关于我可以只验证查询字符串中重复的变量名是否有效吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆