Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 5th, 2004, 05:50 AM
Authorized User
 
Join Date: Apr 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ranakdinesh
Default how to call Application Variable from global .asax

i am new to ASpx coding with C#.
i am created a login page which will lock the user account if he tries more then three times with wrong password. for that i made global.asax file as



 void Application_OnStart(Object sender ,EventArgs E)
{

Application["Hcount"] = 0;
}
     void Session_OnStart(Object sender ,EventArgs E)
 {
Session["tries"] =0;
         // Session start-up code goes here
     }

My Login Form Page Has the following Code genreating error that i cannot use comparison operators Application and Session Variables are objects the code with error is

if (Application["Hcount"] <= Session["tries"])

how i can use these variables in my code sothat they work smoothly as they work when same is written in VB .Net






dinesh Rana
__________________
dinesh Rana
 
Old August 5th, 2004, 07:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Try HttpContext.Current.Application and HttpContext.Current.Session. Don't know if the objects are accessible where they are being created....

Brian
 
Old August 6th, 2004, 06:01 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

dinesh Rana
did you solved your problem I have a suggestion
----
void Session_OnStart(Object sender ,EventArgs E)
{
 Session["tries"] =0;
 while(!Session["tries"] =3)
 {
  // Go to Register page
  if(user/pass==ok) //enter and enjoy(break;)
  else{
    Session["tries"] =Session["tries"]+1;
  }
}
----




--------------------------------------------
Mehdi.:)





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to declare the global variable in global.asax? calyn_gately ASP.NET 3.5 Basics 0 August 6th, 2008 08:06 PM
what is global.asax? gaurav_jain2403 General .NET 1 February 3rd, 2006 02:40 PM
how to call application variable in global.asa mqnguyen Classic ASP Basics 4 July 28th, 2003 11:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.