Of course, I can store a C# class instance to the Server Cache
(this.Context.C ache). I've tried it. My question is, will this destroy the
scalability of my application?
My background is VB6. With VB6 we learned very early on that you do *NOT*
store VB6 class instances on the server. That is because a VB6 class can
only be accessed on the thread on which it is created (thread affinity).
This is just incompatible with stateless web architecture since with this
architecture every client request will likely be served by different ASP
pages executing on different threads. However, if VB6 classes are stored to
the Session object, then the ASP execution is going to block until the
thread on which the class instance was created becomes available.
Is this limitation still inherent with .NET classes, or are .NET class
instances 'safe' in this regard?
(Of course, the solution would be to serialize to XML and store the XML
string, but if I can safely store the class reference, why bother?)
Thanks for your advice!
- Joseph Geretz - 5 2165
"Joseph Geretz" <jg*****@nospam .comwrote in message
news:eO******** ********@TK2MSF TNGP02.phx.gbl. ..
Of course, I can store a C# class instance to the Server Cache
(this.Context.C ache). I've tried it. My question is, will this destroy the
scalability of my application?
My background is VB6. With VB6 we learned very early on that you do *NOT*
store VB6 class instances on the server. That is because a VB6 class can
only be accessed on the thread on which it is created (thread affinity).
This is not a problem with .NET. You have to make sure the class is
serializable.
John
Hi John,
Thanks for your response. I'm not sure what you mean by serializable. Do you
mean that I need to serialize this explicitly into the Cache, or that the
Framework will take care of the serialization for me if the class is
serializable?
Here is that class which I am caching.
internal class SessionCache
{
public string SID;
public string UID;
public string PWD;
public DataTable Profile;
}
I know this is 'working' since I'm able to retrieve this from the cache on
successive Web Method requests. Is this actually being serialized into the
cache for me 'under the hood'? Does it need to be? Do I need to do anything
explicitly to serialize this into the cache?
Thanks for your advice!
- Joseph Geretz -
"John Saunders" <john.saunder s at trizetto.comwro te in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
"Joseph Geretz" <jg*****@nospam .comwrote in message
news:eO******** ********@TK2MSF TNGP02.phx.gbl. ..
>Of course, I can store a C# class instance to the Server Cache (this.Context. Cache). I've tried it. My question is, will this destroy the scalability of my application?
My background is VB6. With VB6 we learned very early on that you do *NOT* store VB6 class instances on the server. That is because a VB6 class can only be accessed on the thread on which it is created (thread affinity).
This is not a problem with .NET. You have to make sure the class is
serializable.
John
"Joseph Geretz" <jg*****@nospam .comwrote in message
news:%2******** *******@TK2MSFT NGP03.phx.gbl.. .
Hi John,
Thanks for your response. I'm not sure what you mean by serializable. Do
you mean that I need to serialize this explicitly into the Cache, or that
the Framework will take care of the serialization for me if the class is
serializable?
Here is that class which I am caching.
internal class SessionCache
{
public string SID;
public string UID;
public string PWD;
public DataTable Profile;
}
I know this is 'working' since I'm able to retrieve this from the cache on
successive Web Method requests. Is this actually being serialized into the
cache for me 'under the hood'? Does it need to be? Do I need to do
anything explicitly to serialize this into the cache?
Joseph, I'm sorry, I wasn't thinking clearly. I was thinking about
ViewState, which _does_ require instances to be serializable. Clearly, the
ASP.NET Cache object doesn't need anything more than your class provides.
John
Thanks John,
Clearly, the ASP.NET Cache object doesn't need anything more than your
class provides
I know this works, but will I run into any threading problems? In other
words, let's say the user logs in with an instance of the ASMX page
executing on thread 345. The SessionCache class instance will be created on
thread 345 and a reference to that class instance will be stuffed into the
Server Cache. Let's say the next transaction for this user's session is
served up by an ASMX page executing on thread 987. Will access to the
SessionCache class instance involve a thread context switch from 987 to 345?
This is the sort of trap which looks like it's working initially, but as
usage scales up, this sort of problem will start to manifest itself in a big
way. (Forgive me for stressing the point, but a lot VB6 developers were
burned badly by saving class instances on the Server and I want to make sure
that .NET class instances aren't succeptible to the same type of thread
affinity problems.)
Thanks!
- Joseph Geretz -
"John Saunders" <john.saunder s at trizetto.comwro te in message
news:OO******** ******@TK2MSFTN GP03.phx.gbl...
"Joseph Geretz" <jg*****@nospam .comwrote in message
news:%2******** *******@TK2MSFT NGP03.phx.gbl.. .
>Hi John,
Thanks for your response. I'm not sure what you mean by serializable. Do you mean that I need to serialize this explicitly into the Cache, or that the Framework will take care of the serialization for me if the class is serializable ?
Here is that class which I am caching.
internal class SessionCache { public string SID; public string UID; public string PWD; public DataTable Profile; }
I know this is 'working' since I'm able to retrieve this from the cache on successive Web Method requests. Is this actually being serialized into the cache for me 'under the hood'? Does it need to be? Do I need to do anything explicitly to serialize this into the cache?
Joseph, I'm sorry, I wasn't thinking clearly. I was thinking about
ViewState, which _does_ require instances to be serializable. Clearly, the
ASP.NET Cache object doesn't need anything more than your class provides.
John
"Joseph Geretz" <jg*****@nospam .comwrote in message
news:eJ******** ******@TK2MSFTN GP03.phx.gbl...
Thanks John,
>Clearly, the ASP.NET Cache object doesn't need anything more than your class provides
I know this works, but will I run into any threading problems?
Joseph, all of that COM-era thread affinity stuff is gone in .NET.
John This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: NWx |
last post by:
Hi,
Is Cache appropriate to store persistent variables used across the
application? What I want is to store UserID for currently logged user,
SessionID (my own SessionID, which keep track of datetime for login and
logout as well as other info, like Client IP , etc)
My objects I want store to cache are not set-up to expire.
Or should I store them better in Session storage?
|
by: Mark |
last post by:
I'm trying to port the asp.net unleashed sample store from SQLServer to
Access. I have it all do, execpt when I try and add something to the cart I
geet this error:
Exception Details: System.InvalidOperationException: OleDbCommand.Prepare
method requires all parameters to have an explicitly set type.
Source Error:
Line 37:
|
by: matvdl |
last post by:
I have a system that was originally developed in asp - the pages are saved in
SQL (there are over 10,000 pages) and saved to a temp directory in the server
when requested by a client.
I have updated this system and changed the pages that are saved to the
server as aspx - everything works fine and pages can be served - but
Its not impossible for a single client to request 100 plus pages in one
session - as each page is requested it is...
|
by: Göran Tänzer |
last post by:
Hi,
i've written a class which does some calculations for my web application.
These informatinos are different for each page request - the current user is
not important.
i have about 10 aspx pages and 20 ascx user controls. In most of these
pages/user controls i need the informations of this class.
First i created an instance of this class in every page/user control i
|
by: Steve |
last post by:
I am developing an asp.net 2.0 application and have come across the
dilemma of how to store constant values, which change infrequently. The
website will have tens of thousands of visitors every day.
Obviously there is the application object route.
However, because of the new feature of sql server cache invalidation,
would it not be best just to create a normal data access layer which
can retrieve a datatable containing the constants...
| |
by: Hans Merkl |
last post by:
Hi,
I am helping to build a web app that's pretty much a wrapper around a web
service. The question now is how to store the handle of the web service
object between requests. My client is using SQL server for session state so
I don't think I can store the web service handle there since it's not
serializable.
Opening up a connection to this particular service is quite slow so I don't
want to reopen it for every request.
|
by: siddharthkhare |
last post by:
Hi All,
what is the diference between these two cache control header.
no-cache and no-store.
I have read the w3.org explanation.
So lets say I am using only no-cache ....my understanding is that
nothing is cached and nothing is writen to disk.
|
by: Joseph Geretz |
last post by:
We use a Soap Header to pass a token class (m_Token) back and forth with
authenticated session information. Given the following implementation for
our Logout method, I vastly prefer to simply code m_Token = null in order to
destroy the session token when the user logs out. However, I'm finding that
setting class instance to null results in no header being sent back to the
client, with the result that the client actually remains with an...
|
by: |
last post by:
Hello all,
I'd like some advices from more experienced python users. I want to
have a class in my python application that does not allow multiple
instance with same "name".
I want to have a class (call it kls) that behave at least following way:
1) New instance has to have a property called 'name'
2) When instance is attemped to created, e.g., x=kls(name='myname'), and
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |