For example, if a query string has 2 expected parameters , say. param1 = "abc"
& param2 = "def"
.
I know that Request.QuerySring["abc"]
will check for "abc" in query string.
But is there any way to validate if user enters anything else other than param1 or param2?
Thanks.
Yes, you can use AllKeys
:
Request.QueryString.AllKeys
To get the list of parameters used apart from 'param1' and 'param2':
var expectedParams = new [] { "param1", "param2" };
var additionalParams = Request.QueryString.AllKeys.Where(k => !expectedParams.Contains(k));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With