Link to home
Start Free TrialLog in
Avatar of Muaadeeb
Muaadeeb

asked on

Object reference not set to an instance of an object. !ISPOSTBACK

Hello,

I am getting the Object Reference message but I am confused because I did create an instance of the base class in the calling program " CheckProgramAccess CPA = new CheckProgramAccess()"

The error is being thrown within the .DLL at this statement:
"string TrackId = HttpContext.Current.Request.QueryString["track"].Substring(0,8) ;"

The Part 2 of the code is in a .dll which I am not allowed to change.  So my question is - two fold:
1). Why is this error happening since I did create an instance as demonstrated by CPA....and
2). How do I resolve this within my Part 1 code sniplet?

Thank you!
Part#1:
 protected void Page_Load(object sender, EventArgs e)
 
        {
        if (!IsPostBack)
            {
            CheckProgramAccess CPA = new CheckProgramAccess();
 
            if (!CPA.Authorized())
                {
                Response.Redirect("/asp/home.asp");
                }
            else
                {
 
                }
            }
=========
Part# 2:
 
public class CheckProgramAccess
	{
		public CheckProgramAccess()
		{
			//
			// TODO: Add constructor logic here
			//
		}
 
		public bool Authorized()
		{
			bool Authenticated = true;
			bool RtnCde = false ;
			string UpId = "" ;
			string TimeOut = "" ;
			string LogTime = "" ;
 
			try
			{
				string TrackId = HttpContext.Current.Request.QueryString["track"].Substring(0,8) ;
				string Program =  HttpContext.Current.Request.QueryString["program"].ToString() ;
	}
			catch(Exception ex)
			{
				string msg = ex.Message.ToString();
				Authenticated = false ;
			}
			return Authenticated;
		}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of GuitarRich
GuitarRich
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Muaadeeb
Muaadeeb

ASKER

Thanks guys you were right.   The query string was null and as a result the .DLL code had no idea what it was supposed to be referencing.


Thank you!