Conditionally check two urls based on "Request.QueryString"
I have a page which will have these urls,
http://localhost:1218/Order-AUG17/Forms/Order.aspx?ContactName=HajaMubeen
and
http://loca开发者_JAVA百科lhost:1218/Order-AUG17/Forms/Order.aspx
and in my page load i have checked this,
if (Request.QueryString["ContactName"] != "")
//My logic
else
//My logic
But this if condition fails for both the urls. Any suggestion.
try
if (Request.QueryString["ContactName"] != null)
//My logic
else
//My logic
if you are trying with
http://localhost:1218/Order-AUG17/Forms/Order.aspx
both will be false only. because no query string is there in the URL.It comes as null
if (Request.QueryString["ContactName"] != "")
//My logic
else
//My logic
if you are trying with
http://localhost:1218/Order-AUG17/Forms/Order.aspx?ContactName=HajaMubeen
if (Request.QueryString["ContactName"] != "")
//My logic
else
//My logic
it will consider the if condition and execute that loop.
精彩评论