Click here to Skip to main content
11,715,022 members (72,352 online)
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 2:58am
Edited 31-Dec-12 3: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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 495
1 Richard MacCutchan 275
2 Maciej Los 259
3 ManasKumarM 155
4 Frankie-C 125
0 Sergey Alexandrovich Kryukov 775
1 CHill60 415
2 Richard MacCutchan 405
3 Maciej Los 389
4 OriginalGriff 320


Advertise | Privacy | Mobile
Web03 | 2.8.150901.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