Check if unassigned variable exists in Request.QueryString

后端 未结 5 622
伪装坚强ぢ
伪装坚强ぢ 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:14

    I use this.

    if (Request.Params["test"] != null)
    {
        //Is Set
    }
    else if(Request.QueryString.GetValues(null) != null && 
           Array.IndexOf(Request.QueryString.GetValues(null),"test") > -1)
    {
        //Not set
    }
    else
    {
        //Does not exist
    }
    

提交回复
热议问题