State Management :: Static/Shared Confusion?
Sep 16, 2010
my understanding static/shared objects will be saved in a memory that is shared by all instances of the asp.net application,so if we set a value to shared object from inst1 & i should be able to access it via instance2(may be in same computer or anywhere)Actually:In my vb.net application,previously they defined shared dataset to hold some information specific to the user,still now i cant reproduce the error that same value shared across all application instances.Please help me to solve or clarify this.
[URL]
View 3 Replies
Similar Messages:
Aug 6, 2010
We have a common problem with tabbed browsing in Internet Explorer is that the session state is shared between the tabs.
Due to this our user can face many issues like
1) Suppose user has opened a .aspx page for (clientId=1) and editing it in one tab and at the same time user is editing another client(ClientID=2). And both are using same in session.
Due to the session sharing when page will auto refresh the first tab with (clientId=1) will see the data of clientId=2.
Its clear that the session is shared between the tabs.
I have also implemented the ASP.NET 2.0 offered solution by way of the following config setting
<sessionState mode="InProc" cookieless="UseUri"></sessionState>
But still our users are facing this issue. I am looking for solution to disabled the Tab programaticaly and also i wanted to know how to clear the cache programatically.
View 7 Replies
May 29, 2010
I am doing a POC of making my website run faster. Currently it stores huge object data in Session while passing information from one page to another. What I was thinking is to use shared methods and properties instead of session. It works, but wanted tocheck if this is an optimum way to do it. Below is the code that does not use session but still pass object data from one page to another:
[code]...
View 1 Replies
May 19, 2010
[Code]....
Above is my configuration.
Because one user is getting the session values of other users due to some reason that I dont know .
View 3 Replies
Apr 14, 2010
I have a Session Varaible in which I am assinged a List of "MLoad" objects (Ex:- 10 MLoad objects) from the initial search. After that basing some icon click i am trying to get the new filtered results (Ex:- say 1 MLoad object) and assigning them to the public property "ListSearchResults" (See code below). When i do this the original results in the Session are changed(10 MLoad objects are getting replaced with 1 MLoad object ==> which just been filtered). What i have to do so that the "ListSearchResults" in Session is not changed. It is now byref, how to make it byval?
in acreate an object See below code and after retreving t
[Code]....
View 1 Replies
Apr 28, 2010
I dont know if im writing in a right place. this is about class in App_Data (asp.net) folder that i want to user throughout system. but specifically for one user.
lets say userA login to the system. then system will use classUser
FillProperty and set variable like Name, Username, UserId (a property of his own, the modifier is
shared). the purpose is so that it can be used in any page. it behaves like
user.identity.name (when we want to call name of user that already authenticated)
I can do it fine. but once i test login with UserB in other browser, it change that shared variable with property of userB.what i want is, when A login, he will set the classUser with his data and data that called by him is his data. and when B login, he will do the same, but he will use his data without replacing userA data.here is the code :
-------------- CLASS -------------[Code]....
View 5 Replies
Sep 17, 2010
I have several web applications on a server using the same application pool. The worker process usually takes a lot of ram but usually only from one application. I can successfully limit the cache usage by setting "PrivateBytesLimit" in web.config file when the application uses it own dedicated application pool.
Does anyone know how this setting will be applied when using shared application pool? Is it per application, per worker process or per application pool? Also if it is not per application which setting from which application will be applied?
View 1 Replies
Sep 24, 2010
I know the big difference, but one thing is confusing me. Cache works only on a single machine on webfarm and to make it globally we use Velocity or memcache.So is static does same, or is it already work globally ?
eg
Cache["someid"] = "value"; //this will only work on single machine cache,
static string abc = "value"; // will this work on single machine or globally ?
View 6 Replies
Jul 3, 2010
Currently I have my data cached in Datasets in a static class. I was talking to my cousin's husband, who works as a C# developer for our local Telecom company.
Basically, I'm pretty new to ASP.NET and although to me having cached data in a static class makes sense to me, when I talked to him about it, he said there might be a problem when the site goes live, as on a web server more than one instance of the class may be created.
He did say this was a theory, and it was an area he didn't know an awful lot about, so I thought I'd ask some of you ASP.NET gurus to see if what I've done is totally wrong or not.
View 12 Replies
Aug 9, 2010
I am working on rewriting an application. The previous developers have declared some Private static hashtables within a class in a class library. The first time when the application runs, this hashtable gets populated by running the query. After that this hastable is refrenced elsewhere to get the employee information.Even if the employee is removed from the DB, he is still able access the application, Since the private static hashtable holds the employee information. I totally understand that the hashtable is referenced to prevent the DB calls everytime.
The problem is even after closing the browser and restarting the application the hashtable holds the employee information. How do i get clear this so that it calls the DB?
View 9 Replies
Mar 25, 2011
Which one is faster? For a dropdownlist binding it the first time and using ViewSate or Turning of viewstate, keeping the data in a static datatable and binding the dropdownlist each time on a postback
View 7 Replies
Oct 29, 2010
I am creating a static variable and adding to session.This variable has value that is user specific. Now I am getting a problem with this users are complaining that they are getting values that should be another users. It's like a mix up with session. Could this be because of static variable declaration?
View 2 Replies
Jul 2, 2010
What is difference between Application object and static variable? Where these are stroed in memory.
View 4 Replies
Oct 17, 2010
I want to know , how good / bad is it to save configuration values in a static properties?I am creating an application which reads configuration from an XML file and a DataContext file, instead of sending the CustomConfig class into the configuration.xml each time I tought about using an ReadXml() method on application_start at the global.ascx
the ReadXml() method would save the data in static properties of CustomConfig and whereever I would want to read that particler data I would ask CustomConfig.PROERTY_NAME
My question is ? how smart it is ? how long does IIS would save the data in a static member? (if as long as the application exists then I'm ok as long as I add the ReadXml() in the application_start)
View 2 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
May 7, 2010
I'm building an online system to be used by school groups. Only one school can log into the system at any one time, and from that school you'll get about 13 users. They then proceed into a educational application in which they have to co-operate to complete tasks, and from a code point of view, sharing variables all over the place.
I was thinking, if I set up a static class with static properties that hold the variables that are required to be shared, this could save me having to store/access the variables in/from a database, as long as the static variables are all properly initialized when the application starts and cleaned up at the end. Of course I would also have to put locks on the get and set methods to make the variables thread safe.
Something in the back of my mind is telling me this might be a terrible way of going about things, but I'm not sure exactly why, so if people could give me their thoughts for or against using a static class in this situation,
View 1 Replies
Mar 4, 2010
I have a base class with several derived classes. I want all of my derived classes to have the same Public Shared (static) method with their own implementation. How do I do this?
View 3 Replies
Aug 20, 2010
I get this error: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
Partial Class _Default
Inherits System.Web.UI.Page
<WebMethod()> _
Public Shared Function ParseData() As String
Dim value as string = GetValue()
End Function
Private Function GetValue() as String
Return "halp"
End Function
End Class
I know it has something to do with the fact that the first function is shared and the second function should probably be Public as well but I don't fully understand the reason behind it. Probably not relevant but I'm calling the web method from some javascript.
View 1 Replies
Nov 11, 2010
For reasons I would rather not discuss, I need to create a custom authentication system for my app. I was just reviewing the system and am having some doubts if my solution is thread safe. My goal was to create a solution that would allow my app to authenticate a user one time and that users authentication info would be shared by all master pages, pages, classes, user controls, etc that are used. (But not share the same info between users) Here is my setup: PageHttpModule.cs - this is added to the web.config as a httpModule.
public class PageHttpModule : IHttpModule
{
public void Init(HttpApplication app)
{
app.AuthenticateRequest += new EventHandler(OnAuthenticateRequest);
}
public void OnAuthenticateRequest(Object s, EventArgs e)
{
CurrentUser.Initialize();
}
public void Dispose() { }
}
CurrentUser.cs
public static class CurrentUser
{
public static bool IsAuthenticated { get; private set; }
public static string Email {get; set;}
public static string RealName {get; set;
public static string UserId {get; set;}
public static void Initialize()
{
CurrentUser.AuthenticateUser();
}
Note: this is a scaled down version of my authentication code.
public static void AuthenticateUser()
{
UserAuthentication user = new UserAuthentication();
user.AuthenticateUser();
if (user.IsAuthenticated)
{
CurrentUser.IsAuthenticated = true;
CurrentUser.UserId = user.UserId;
CurrentUser.Email = user.Email;
CurrentUser.RealName = user.RealName;
}
}
}
UserAuthentication.cs
public class UserAuthentication
{
public string Email { get; set; }
public string RealName { get; set; }
public string UserId { get; set; }
public bool IsAuthenticated { get; private set; }
public UserAuthentication()
{
IsAuthenticated = false;
Email = String.Empty;
RealName = String.Empty;
UserId = String.Empty;
}
public void AuthenticateUser()
{
//do some logic here.. if the user is ok then
IsAuthenticated = true
Email = address from db
UserId = userid from db;
Realname = name from db;
}
}
I have tested between 3 different browsers and it seems to work fine, but I am still learning and don't want to make a huge mistake. If my logic is totally wrong, then how should I do it so I dont have to put user lookups on every page directly?
View 4 Replies
Apr 30, 2010
If for example you have a function Public shared function GetStockByID(StockID as Guid) as Stock Is that function common to all current users of your application? Or is the shared function only specific to the current user and shared in the context of ONLY that current user? So more specifically my question is this, besides database concurrency issues such as table locking do I need to concern myself with threading issues in shared functions in an ASP.Net application?In my head; let's say my application namespace is MyTestApplicationNamespace. Everytime a new user connects to my site a new instance of the MyTestApplicationNamespace is created and therefore all shared functions are common to that instance and user but NOT common across multiple users. Is this correct?
View 2 Replies
Feb 25, 2011
when we go for client and server side state management in asp.net
View 2 Replies
Nov 18, 2010
i have a form on page1.aspx with several controls (textbox, dropdownlist, etc).on Page1 PageLoad event i load data from database and performe databinding.From Page1 a user can, by clicking a specific button, move to Page2.aspx to insert some details and, after saving details, he returns to page1.
if save changes are made on control on page1 before save them to db, obviously, these are lost on return from page2 (because are reloaded on pageload from db).How can i save control status between pages round trip?
View 3 Replies
Aug 16, 2010
i need to know the full concepts state manegemnt in asp.net,..in which site i will get the correct concept for state management....
View 4 Replies
Jan 5, 2010
let me know what does these access modifiers means.private shared vs public shared vs protected shared
View 5 Replies
Oct 2, 2010
User Interface: 2 Labels; 1 Buttons
Requirements: Create a Web Page in ASPx that will do the following:
1)One label will provide a count of how many times Button 1 has been clicked in the current session.
2)One label will provide a count of how many times Button 1 has been clicked by all users of the application. The Application Code for the Button should start at 100 (set this in the Global.asax file). this is what i have so far but i cant seem to get the application state to work properly.
aspx.vb
Partial Class _Default
Inherits System.Web.UI.Page
Dim clickcount As Integer
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Session("ClickCount") Is Nothing Then
clickcount = 0
Else
clickcount = CInt(Session("ClickCount"))
End If
If Not IsPostBack Then
If Request.Cookies("UserName") IsNot Nothing Then
Label1.Text = "Welcome Back " & Request.Cookies("UserName").Value & "."
End If
End If
Dim clickCounta As Integer = CInt(Application("ClickCount"))
End Sub
Protected Sub PostBackSession_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PostBackSession.Click
clickcount += 1
lblClkCnt.Text = "Current Click Count is " & clickcount
Application.Lock()
Dim clickCounta As Integer = CInt(Application("ClickCount"))
clickCounta += 1
Application("ClickCount") = clickCounta
Application.UnLock()
AppClick.Text = clickCounta
Dim nameCookie As New HttpCookie("UserName", _
TextBox1.Text)
nameCookie.Expires = Now.AddYears(1)
Response.Cookies.Add(nameCookie)
End Sub
Protected Sub PostBackSession_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles PostBackSession.PreRender
Session("ClickCount") = clickcount
Application("ClickCount") = clickcount
End Sub
End Class
global.asax
<script runat="server">
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim clickCounta As Integer = CInt(Application("ClickCount"))
Application.Add("ClickCount", 0)
End Sub
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
Dim clickCounta As Integer = CInt(HttpContext.Current.Application("ClickCount"))
End Sub
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
End Sub
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
End Sub
View 3 Replies