Click here to Skip to main content
12,394,882 members (78,923 online)
Rate this:
 
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 2:58am
Updated 31-Dec-12 3:00am
v3
Comments
zarna vaishnav 31-Dec-12 9:05am
   
hEY..REPLY ME AS SOON AS POSSIBLE I'M STUCK IN THIS..
Sandeep Mewara 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 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 31 Dec 2012
Copyright © CodeProject, 1999-2016
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