Check if unassigned variable exists in Request.QueryString

后端 未结 5 617
伪装坚强ぢ
伪装坚强ぢ 2021-02-07 05:59

Within the context of an ASP.NET page, I can use Request.QueryString to get a collection of the key/value pairs in the query string portion of the URI.

For example, if I

5条回答
  •  臣服心动
    2021-02-07 06:36

    Request.QueryString is a NameValueCollection, but items are only added to it if the query string is in the usual [name=value]* format. If not, it is empty.

    If your QueryString was of the form ?test=value, then Request.QueryString.AllKeys.Contains("test") would do what you want. Otherwise, you're stuck doing string operations on Request.Url.Query.

提交回复
热议问题