State Management :: Looking For A Way to Declare A Global Variable?
May 14, 2010
I'm looking for a way to declare a global variable (so all pages could see) but personal (so if one user puts some value in it, it won't matter to another user or change his value).Sessions and hidden fields won't do. I've tried working with declaring keys in Web.config but unfortunely, the keys values aren't personal, and all users share the same key value.Another way I was thinking was maybe classes, but perhaps there might be an easier solution?
View 19 Replies
Similar Messages:
Jan 2, 2011
i want to declare a variable in page load{} as global so that i can monitor it so that it is not recreated each time
View 4 Replies
Oct 31, 2010
I have to define a global and unchangeable variable in a web page. I used static variable but its content is the same for all users that use the page and it is bad. I dont want use Session variable.
View 5 Replies
Nov 18, 2010
I need to keep a global variable throughout the whole time the user is at my site, but do I use Application or a static class? The string variable should store a region name and my site makes a few changes depending on which region that has been set.
I read that Application was mainly for classic ASP, but I also read that a static class cannot be instantiated at runtime (e.g. when the user has logged in).
So, have I got something wrong here and which solution do I use?
View 2 Replies
Jun 23, 2010
Not sure if this was the forum to post under but here goes. I want to make a global variable counter that I can adjust in my code in the webforms. For example, I want to use the counter like so...
[Code]....
If anyone knows how to create this dynamic global variable or if anyone can tell me if its not possible,If it is not possible,
View 3 Replies
Jun 4, 2010
I've began working with asp.net mvc very recently and I've ran into a problem.I've got an aspx page which renders a few ascx pages. What I'd like to do is declare a global var at the aspx page so it is visible to all its childs. I tried <% var i = 0; %> but it wasn't visible at the child pages. What could I do?
View 4 Replies
May 15, 2010
I would like know how to declare a global variable that can be used within a user after the user login and before the user logout across all the possible pages.
I need to develop a web application that will connect to 5 different servers depends on the selection of user on what server they wish to connect and after they select a server and login...I will need to keep track the server name in a variable last until the user logout (user may visit various pages but the server name MUST NOT be changed due to other user login into different server). So how can I do it so that other users may select different servers and will keep the server name for each different users.
Let says:-
User A selects Server A and login and User B selects Server B and login at the same time, so how the global variable can handle the needs for each user (User A & B) with different server select?
Is "Session" the only way to fulfill the above? I think of using Application State but it seems that the value stored will be shared by all users and not for a particular user.
View 1 Replies
Aug 26, 2010
How to declare a global variable or a public sub in a web application that all aspx pages can have access to?
View 5 Replies
Jun 16, 2015
how to declare global variable in master page and use it in all pages
View 1 Replies
Sep 14, 2010
I added the following code to global.asax to load up several session variable when a session starts. I'm assuming that when a page goes to use the variable that I should be
1) checking at the page level that the value is valid not 0 when its not expected to be 0, not a zero-length string when its expected to have a length
2) have code at the page level that sets the values if the values have not been set as when the Session timeout, ideally putting the code in a class derived from Page and then deriving all of my pages from the new class so that the code does not have to be repeated in every page
[Code]....
View 7 Replies
Dec 9, 2010
can we grab a global variable or Session or View State variable in the javascript or using jquery?
View 2 Replies
Feb 2, 2011
I am trying to set a session variable in the global.asax file and keep running into the problem that the Session is null.
I am running my application in VS2008 and using asp.net 3.51.
Here is my code:
1. In my web.config file I have enabled the session state and added the following line;
<sessionState
cookieless="false"
mode="InProc"
timeout="60"
></sessionState>
2. In the Session_Start procedure in the Global.asax file I set the session variable to a default value.
[Code]....
My problem seems to be that when the Application_Error procedure is executed the session state is lost.
Does anyone know why the session state isn't available in the Global.asax file.
View 9 Replies
May 17, 2010
I have a web application which uses a session variable to store the logged in userid. If no user is logged in, of course this variable will be empty and the contents displayed on my website are meant for guests. If there is a user logged in, the user specific controls/access/links will then be a displayed.
I am now having issues with my hosting where on shared application pool, the worker recycle is triggered every 90 minutes, this will clear sessions causing all my users to be logged out. I opted for a dedicated application pool, which got worse because I am only allocated 50MB memory limit and if this is reached, the worker recycle is triggered and I lose my sessions again. I have tried as much as possible optimization techniques, e.g. dispose where possible, close connections, disable viewstate for static controls etc but my memory per instance keeps building up from page to page without any signs of improvement. I don't use loops nor store huge objects like bitmaps etc but my sessions are now gone even faster than 90 minutes in shared application pool before.
I have considered using SQL Session State but there isn't a simple guide on using this with MySQL. I am getting desperate and considering using a public variable, a string as a replacement to store logged in user id instead of in a session variable. I am pretty sure this will solve my issue with sessions being recycled but are there any negative consequences of doing this? One problem I can think of is if the user closes the browser, the system will never know that the user is now logged out and this public variable should be nothing. In this scenario, will the GC eventually clear this abandoned public variable.
View 10 Replies
Dec 3, 2010
I am building a web app that is limited to one database, therefore I cannot use the ASP.NET config tool. As a quick means of getting this app online, I tried to use a simple session variable. The login page verifies the user's credentials, and if they pass, it sets the session variable to a certain value. All other pages check in the page_load event whether or not the session variable is equal to that value. The problem is that once being logged in for a short while and sending and recieving some data, the session variable resets, and I'm returned to the login page to repeat the process. Here's the basic code from my webforms:
[code]....
Is there some setting I need to change in the web.config file to adjust the cookie timeout or is that only for the config tool authentication methods?
View 5 Replies
Mar 20, 2010
how to get sessions in the global.asax, but I still cant get it to work...for some reason my session throws NullExceptions..the sessions are set from another page add looks something like:
[Code]....
And once I try to get those session values I do the following in the Global.asax:
[Code]....
But as I said, for some reason I get a NullException once I try to get the values...and they do have the same session-name,so they shouldn't be null..
View 6 Replies
May 21, 2010
I want to use something better thatn using the session to store global values, because it has somw problems
View 4 Replies
Dec 20, 2010
i dont know about Global.asax so give some information about it and also tell me about the implementation and use of session_start and session_end event. How to call Global.asax in our website.
View 5 Replies
Nov 11, 2010
i'm using asp.net 2.0.
there's a way to add an handler to manage the session_end event without using the global.asax?
(i can't modify my httpapplication code so i need to add the handler externally to it)
View 2 Replies
Apr 6, 2010
When i start the application, based on some condition in global.asax page,i wil redirect to login page.If i click the logout button,
there i vil be clear all session value. here i want to initiate new session value like Session["InitialLogin"]="Yes".
How can i get this value in global .asax page. If get that session value [i.e Session["InitialLogin"]="Yes"], i vil redirect to some other page.
I cant able to get session value in global.asax page.i always getting null value.
View 7 Replies
Oct 6, 2010
I have a simple aspx Page, which html contains:
[Code]....
and code behind:
[Code]....
This is quite simple. When I press btn1, it sets correctly the Session Key. And this is then the issue arrives: When I press one of these buttons, this is the sequence of what happens:
Global.asax: Session_Start
MyPage.aspx: Page_Load » btnX_Click
So, everytime there is a PostBack, even before the Page loads, the session starts and generates a new Id. This way, I loose everything during the PostBack. My Session State configuration:
[Code]....
This is running on VS 2010 + V3.5, on IIS5.1. The Page header configuration is default.
View 6 Replies
Dec 1, 2010
Suppose my website address is like http://localhost/MyWebsite
I wanted to access this url in Application_start event in global.asax, Can i some how get it?
[I know i can get it via application_beginrequest or other event]
View 17 Replies
May 23, 2010
What is the difference between the 2? Ex:
Private Sub Globals_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.BeginRequest
vs
Protected Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
View 3 Replies
Sep 3, 2010
I have a custom class that pulls user information from a SQL Server table. Now that I'm expanding the site from a single page to others. I want to shift the code to the Session_Start event so that the information is always loaded when the site is accessed. How do I call my custom code from global.asax since its script and not a class.
View 5 Replies
Jan 4, 2011
how can I implement a Global Session in my ASP.NET 3.5 website in C# using Global.asax file ?
View 18 Replies
Sep 29, 2010
can you tell Will sessions kill when application error occurs which is in global.aspx ?
ex:
[code]....
View 1 Replies