Vb.net - Singleton IN Per Session Or Per Machine?
Sep 8, 2010
I have an web application written in ASP.NET (FW 3.5) (along with some VBScript, this is a legacy app) that uses a utility class in the backend that logs error. I need to log several values that a user has entered in the front-end. Since the utility class has no access to the front end (or any HTTP services), i created a singleton class within the utility namespace that my front end UI can access and store information about the user.
I guess more specifically, I am wondering if there's a way to store session variables that can be shared across the web application and web services through a class referenced by both of the application and web services. For example, I have an error handling class that is used by both instances that required information about the user. Is there a way to create a per-session singleton to hold that information, so that my error class will have access to the user info? or is this not possible - that i'll need to pass the information around as they are needed?
View 1 Replies
Similar Messages:
May 12, 2010
I have a web application where I would like to pull user settings from a database and store them for Global access. Would it make more sense to store the data in a Singleton, or a Session object? What's the difference between the two?Is it better to store the data as an object reference or break it up into value type objects (ints and strings)?
View 3 Replies
Mar 27, 2010
which one is better in "Session Facade Class" and "Singleton Object" design patterns in ASP.Net? Also, please state the scenarions where specific design pattern is advisable to use.
View 1 Replies
Nov 10, 2010
I am using ShDocVW.InternetExplorer class to spawn a new internet explorer object and to do some form filling stuffs(for some sharepoint works).It works fine in my own machine which has Windows 7 as the OS. But when I deployed the same thing in windows server 2003 machine, it does not pop up the internet explorer window. When I check the Task Manager, I could see a new iexplore process, but with Session ID = 0 (but session ID = 1 in windows 7). So, I see this is something regarding IIS Session isolation.So, is it possible to assign a ShDocVW.InternetExplorer instance to kind of a new System.Diagnostics.Process and achieve this task? Or can we start a new ShDocVW.InternetExplorer instance with session ID = 1?
View 3 Replies
Mar 24, 2010
1. ASP.Net WEB server.
2. I have PC, on which file to copy to device is located, with Active Sync installed and IE running which has a page in that IE has rendered by server #1.
3. I have a DEVICE connected to desktop #2 via AS.
I would like to copy file from a local machine to the device which is connected to this machine. My application is located in a webserver.
View 5 Replies
Sep 22, 2010
On one of my pages I display a datetime (from a database) and it is formatted correctly as a UK date time (dd-mm-yyyy) on my local machine. However when I deploy it to a server it reverts to American format (mm-dd-yyyy). Does anyone have any idea of when this might be happening?This might be outside the scope of stackoverflow
View 3 Replies
Aug 4, 2010
I have a class which fetches the data from the database. Say First name, Last name , Telephone number etc and display it in my .aspx page. This data is common to all the users. So i would like to use Singleton pattern so that the object is not created again ,just use the created object for all the users. Can any one help me with the simple code snippet example.
View 3 Replies
Mar 17, 2010
I basically want to transfer a file from the client to the file storage server without actual login to the server so that the client cannot access the storage location on the server directly. I can do this only if i manually login to the storage server through windows login. I dont want to do that. This is a Web-Based Application.
protected void Button1_Click(object sender, EventArgs e)
{
filePath = FileUpload1.FileName;
try
{
WebClient client = new WebClient();
NetworkCredential nc = new NetworkCredential(uName, password);
Uri addy = new Uri("\\192.168.1.3\upload\");
[code]...
View 2 Replies
May 23, 2010
I have a lot of Singleton implementation in asp.net application and want to move my application to IIS Web Garden environment for some performance reasons.
CMIIW, moving to IIS Web Garden with n worker process, there will be one singleton object created in each worker process, which make it not a single object anymore because n > 1.
can I make all those singleton objects, singleton again in IIS Web Garden?
View 1 Replies
Sep 16, 2010
i'm building a web application with asp.net c# and i have a class that i want to use in multiple pages witouth instantiate it every time. I need to load the data in it and never lose them during the user session time. I thought about the singleton-pattern but it shared the instance of the class beetween browsers.
View 4 Replies
Jun 16, 2010
I am working on singleton desing patterns and want some real world example of design patterns.Can you please give me an example how you have used singleton pattern in you project. I would appreciate if you can provide code.
View 3 Replies
Dec 1, 2010
I am creating a singleton object in the first request to the web service and keeping it in the memory. This works fine for first few seconds. If I make a request 5 minutes later, I can see that the singleton object is created again? is my singleton object getting disposed after x no of minutes? how can i make increase the life-time of my object forever ?
public sealed class Singleton
{
static ServerInstance instance = null;
static readonly object padlock = new object();
Singleton() {
}
public static ServerInstance Instance {
get {
lock (padlock) {
if (instance == null) {
instance = new ServerInstance();
}
return instance;
}
}
}
~Singleton()
{
#if DEBUG
ExceptionFactory.Fatal("~Singleton() called!");
#endif
}
}
[WebMethod]
public string OnReceiveEvent(string objectXmlData, string objectType) {
if (!Singleton.Instance.initServerComplete) {
InitServer();
}
return Singleton.Instance.OnReceiveEvent(objectXmlData, objectType);
}
public void InitServer() {
if (!Singleton.Instance.initServerComplete) {
Singleton.Instance.InitServer();
Singleton.Instance.initServerComplete = true;
GC.KeepAlive(Singleton.Instance);
}
}
View 2 Replies
Dec 14, 2010
Quick question regarding the use of Singleton lifestyle in Windsor, and Asp.Net MVC. If the following class is registered as a singleton am I correct in thinking that I will have a race condition?
public class UserMapper : IMap
{
public void Map(MyDto dto, MyDomain domain)[code]...
View 1 Replies
Feb 9, 2010
I'm developing a blog application shared by non-profit organizations. I want each organization to be able to change their own blog settings. I have taken a singleton pattern (from BlogEngine.net) and modified it. (I understand that it is no longer a singleton pattern.) I have tested this approach and it seems to work fine in a development environment. Is this pattern a good practice? Are there issues, which may arise when this is placed in a production environment?
public class UserBlogSettings
{
private UserBlogSettings()
{
Load();
}
public static UserBlogSettings Instance
{
get
{
string cacheKey = "UserBlogSettings-" + HttpContext.Current.Session["userOrgName"].ToString();
object cacheItem = HttpRuntime.Cache[cacheKey] as UserBlogSettings;
if (cacheItem == null)
{
cacheItem = new UserBlogSettings();
HttpRuntime.Cache.Insert(cacheKey, cacheItem, null, DateTime.Now.AddMinutes(1),
Cache.NoSlidingExpiration);
}
return (UserBlogSettings) cacheItem;
}
}
}
(Portions of code were omitted for brevity.)
View 3 Replies
Jun 28, 2010
I have searched deference between Static and Singleton Patten on google but did not get it clearly.
View 12 Replies
Nov 17, 2010
I have some confusion with singleton class, below are my some points:
1.Can singleton class have static method?,if yes then how we call that methods?
2.what is main difference between Static class and Singleton Class?
I have created my singleton class as follows:
[Code]....
In Above class structure I have created two method one is Static and second is non static, When I am trying to access Static Method it gives me compile time error.
How can I use static method of singleton class?
View 7 Replies
Apr 19, 2010
I have a whole bunch of data access methods where in each one I am doing this
[Code]....
and them moving on with my SqlCommand and SqlDataReader and so on.Is this creating to many instances of an SQLConnection?I was thinking doing this instead. Creating a SqlConnection Manager which would look like this
[Code]....
and then in my database access methods
[Code]....
Is this a good or bad idea and why?Also would this even be neccesary?
View 2 Replies
Aug 19, 2010
I know what Singleton Pattern means and Abstract class means.What I wanted to know was how would this apply to real world.Could anyone give me any good example or simple explanation.Say I have a simple website, why would I use any of the above if any.Why would it simplify my architechture.
View 3 Replies
Mar 30, 2010
See in below I have writtine a
1. Singleton class Emp1 with Display Method and
2. Static Class with Static Method Display.
What is the advantage of singleton class over Static Class with Static members?
[Code]....
View 9 Replies
Jul 22, 2010
I have set the instanceContextMode to single to create a singleton class.I use the join to add a user to the list, and getuserlist() to retrieve the users. I added a service reference opened two browsers , made sure i simulated it such that i am adding two seperate users , and display the users returned by getuserlist. But its always displaying only one user , the current user. I also have a counter
private static int counter = 1
public int returnCounter()
{
return counter++;
}
This is returning incremented values when i open it in different browsers , but the list is always getting overritten. I am running this as a managed windows service, wsHttpBinding , and my client is a website accessing this service.
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]
View 1 Replies
Oct 25, 2010
Just wanted to know if a singleton class could be inherited and derived.
View 2 Replies
Jun 25, 2010
If I were to use singleton pattern for menu, would that cause that menu to be created once for application session or once for each user session. Obviously, I want something that will create menu items once per application session.
View 2 Replies
Jan 25, 2010
want to make sure I am not assuming something foolish here, when implementing the singleton pattern in an ASP .Net web application the static variable scope is only for the current user session, right? If a second user is accessing the site it is a different memory scope...?
View 4 Replies
Jan 7, 2011
I need to create a singleton that would hold lots of data for a spedesign patterns - Singleton behavior with multi-user requests in ASP.NETcific user. However, I am not unclear as to what the behavior of that singleton is in regard to multi-user app requests.
Here is the scenario:
On AppStart event I want to load common data for all users (from SQL) and store it as a collection somewhere within the ASP.NET storage mechanisms.
If I store that data in the cache, I would also have to create a static property in the Global.asax that would provide access to that the data from the cache.
This is not ideal because whenever an instance of any particular page, or generic handler, or what have you tries to query this data using Linq the property has to load the data from the cache... introducing latency. I need this data to be immediately available. (think of it as about 5K rows of data stored in collection of objects...)
I was thinking to use a singleton to get that data, and store it but I don't know how it would behave between requests (and postbacks), as well as application instances, in terms of its persistence.
On PostAuthenticate event I want to get user specific data from SQL in the form of a collection. If i store it as a singleton (in a similar manner as the common data) i am not clear as to:
How is the data persisted? What is the scope of that singleton (it should be for the duration of the user session). How can I ensure that the data is immediately available to whatever needs to consume it?
What happens between post-backs to that singleton? If another user logs in would another instance of that singleton be created for that specific application instance?
View 1 Replies
Jun 2, 2010
If I run below ASP.NET code, it gives me same output in different post-backs. First Time
Name is = Smith
also After Post-back (Button Click)
Name is = Smith
I feel though I have defined singleton, it should return a new object every time in different ASP.NET post-backs. because once the function "PAGE_LOAD" is completed then there are no reference variables holding singleton object. So there is a change of unloading the singleton class from memory by CLR. that means there is a chance of losing private static reference variable and also single ton object stored. In ASP.NET stateless environment, why is it keeping earlier object in multiple post backs and btw, without having any reference variable to that object. Is this is known danger with singleton in ASP.NET environment?
[Code]....
View 4 Replies