Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
hello,
 
i have one problem when i'll redirect from my class file than nullexception is fired but its only happen when my timer is called this class file..
 
my code is here:
(AccessRights.cs)
 
  try
                {
                    myConnection.Open();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
                SqlDataReader myReader = null;
                App.Global app = new App.Global();
                string important1 = app.ImportantData;
               
                string query = "SELECT     tbl_ApplicationAccess.Access,tbl_ApplicationAccess.Component1, tbl_ProductPurchaseMaster.ProductKey FROM tbl_ProductPurchaseMaster INNER JOIN tbl_ApplicationAccess ON tbl_ProductPurchaseMaster.CustomerRegistrationId = tbl_ApplicationAccess.CustomerID where tbl_ProductPurchaseMaster.ProductKey='" + important1 + "'";
                SqlCommand myCommand = new SqlCommand(query, myConnection);
               
                myReader = myCommand.ExecuteReader();
                string cmpnyname = "";
                string Access = "";
                while (myReader.Read())
                {
                    Access = (myReader["Access"].ToString());
                    cmpnyname = (myReader["Component1"].ToString());
                   
                }
                if (Access.ToLower() == "false")
                {
                    HttpContext.Current.Response.Redirect("../PageAccess.aspx");//IF TIMER CALL THIS SATATEMENT THAN ITS OCCURE NULLEXCEPTION ERROR OTHERWISE WORKING FINE
                }
                else if (Access=="")
                { HttpContext.Current.Response.Redirect("../PageAccess.aspx"); }
            }
Posted 31-Dec-12 3:58am
Edited 31-Dec-12 4:00am
v3
Comments
zarna vaishnav at 31-Dec-12 9:05am
   
hEY..REPLY ME AS SOON AS POSSIBLE I'M STUCK IN THIS..
Sandeep Mewara at 31-Dec-12 15:48pm
   
My guess, 'HttpContext.Current' has no value when your timer calls. Since you have not clearly mentioned about how and when you call that using a times, it would be difficult for anyone to comment much.
zarna vaishnav at 1-Jan-13 1:38am
   
i have calling AccessRights.cs file from timer.cs than d actually happen is HTTP.Current.responce.redirect thrown error and d reason is HTTP.Current is Null so how can i solved it out.???

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web01 | 2.8.150327.1 | Last Updated 31 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100