object pageType = Session["Pagetype"];
if ((!string.IsNullOrEmpty(pageType.ToString()) &&
(pageType.ToString() == "EXIST" || pageType.ToString() == "Preview")))
|| !String.IsNullOrEmpty(qID)
what is likely happening is that the Session["Pagetype"] is coming back null and as such you cannot take the .ToString() of a null object. you have to test it first for null
another way to write it is
object pageType = Session["Pagetype"];
if (!string.IsNullOrEmpty(pageType.ToString()))
{
if (pageType.ToString() == "EXIST" || pageType.ToString() == "Preview"
|| !String.IsNullOrEmpty(qID)
{
}
}