ASP实现IE地址栏参数的判断
程序员文章站
2023-12-30 21:40:22
当地址栏没有参数"id"时: Request.QueryString["ID"] == nullConvert.ToString(R...
当地址栏没有参数"id"时:
Request.QueryString["ID"] == null
Convert.ToString(Request.QueryString["ID"]) == null
注意这样会出错:
Request.QueryString["ID"].ToString();
当地址栏有参数"id",但没有赋值的时候:
Request.QueryString["ID"] == ""
Request.QueryString["ID"] == String.Empty
Convert.ToString(Request.QueryString["ID"]) == ""
Convert.ToString(Request.QueryString["ID"]) == String.Empty
同时判断二个条件的时候:
if ("" + Request.QueryString["ID"] == "") {...}
if (("" + Request.QueryString["ID"]).Length == 0) {...}