I've got a page in my Intranet app where sometimes there's a variable attached and sometimes there isn't. For instance, in my pagination code, I've got this:
MenuItem itemMessage = NavMenu.FindItem("First");
itemMessage.NavigateUrl = Request.CurrentExecutionFilePath + "?page=1&sid=6";
and for other sections I have this:
MenuItem itemMessage = NavMenu.FindItem("First");
itemMessage.NavigateUrl = Request.CurrentExecutionFilePath + "?page=1";
Sometimes sid is passed to the page, and sometimes it's not.
The problem is, on the other end, I'm trying to read the values like this:
var queryStrings = HttpUtility.UrlDecode(Request.QueryString.ToString());
var arrQueryStrings = queryStrings.Split('&');
var part1 = arrQueryStrings[0];
var part2 = arrQueryStrings[1];
If sid isn't passed, I get an error for part2 because it's outside the scope of the array.
Any idea how to handle this?