IIS Does Session State persist across different applications (InProc) - asp.net

I have to different ASP.NET applications (same version) running on the same IIS Server and I have Sessions running In Process. Will the session state/variables persist across the two applications? I found a similar post where someone asked the same question but they were managing sessions in SQL Server and someone pointed out explicitly that session state doesn't persist (out of the box) across two applications of Sessions were maintained using SQL Server. It made me wonder if the same applies by default for two applications where the sessions are maintained in process.

No there is custom code needed.. best way that I found to do this.. is to have the referring page pass its session id and application name, then SQL stores the Session Data in a table using the [sessionid][appkey]... we use a reference table that I manually build to figure out the appkey for each new application... then I wrote a DLL that takes the string in and pulls the sessiondata from the DB and packs it in to the new pages current session.. Its a little tough to wrap you head around, but I can supply the DLL and how to use it if you want. Just PM me and ill get that DLL for you.

Related

Have coldfusion and asp.net share session variables

I am looking for a way to have ColdFusion and ASP.NET share session variables. I have seen posts in the past saying that you cannot do this directly with out calling some sort of ColdFusion function to return some sort of string representation of the session. I have recently learned about something called ehcache that is a third party session storage tool. That got me wondering is there a third party session tool that will allow ASP.NET and ColdFusion to share a session.
Some details about our systems:
They are running Windows Server 2008
We are using IIS
We are using ColdFusion 9
ColdFusion/Railo and asp.net can use EHCache, but they're very unlikely to share sessions out of the box. Each will have their own session key, which they'll use to put the data in/out. They'll all have their own way of storing the data. I may be wrong, but from memory, ColdFusion uses WDDX, Railo uses something like JSON and I've no idea what the .Net platform uses.
The point is that each hides the complexity of dealing directly with ehcache, but they each do it in their own way. If you want to interoperate, you may need to have each read/write directly to ehcache (or the database). You'll also have to work out a way of sharing a common key between .Net and ColdFusion.
If you're rolling your own version of this, then using JSON proably makes sense as the common format.

How Can I Use Classic ASP Session Object in ASP.NET to Read Session Variables

Background:
I'm developing an ASP.NET application for a classic ASP website
User authentication is performed by the classic ASP website
The classic ASP website stores data in session variables to identify authenticated users
I need to read the data in those session variables in my ASP.NET application
Many articles say that you need to store session state in a database in order to do this.
None of them have mentioned about using VBScript objects from within the VB.NET code.
Is it possible to do this? Can I not simply reference a COM library in my application and use the objects and their methods? If not, how come?
Session variable values are not just the result of a function call. They depend on IIS and other tools to uniquely identify the user. It isn't possible to directly retrieve session state across these two frameworks.
Of course, depending on how sensitive the data is,you could hack it. Make an Ajax call in the background to retrieve session data from a custom page and feed it into the .NET session. It's a hack and a security risk, but it would work.
Several solutions..., here is a recent one
http://weblogs.asp.net/lichen/archive/2011/10/30/sharing-session-between-asp-classic-and-asp-net-using-asp-net-session-state-server.aspx
There are also other solutions, google for session share asp.net asp you'll find many solutions including solutions by ms herself.

SQL Server State for large asp.net application and any advantages of writing own Custom Store Provider

Background
We have a large asp.net application and uses a lot of sessions like datasets, datatables etc.
We want to support web farms for this application, so we want to save the session state in sql server.
I am successfully storing all the required data into the sql sever and getting all the data fine as well.
Our supported database is SQL Server 2005-Sql Server 2008.
We have to store datatables and datasets in sessions, even we know it is going to be bit expensive.
Question
I want to know from other developers is there any advantage of using Custom Store Provider to store data. (any help in debugging or error finding or future proofing etc.)
Or i just change the web config and make all the classes serializable to make it work.
Any custom way to make all the related classes serializable using c# code.
Any better way to intervene the process used by .net to store data in sql server (default process on changing web config)and make it better, by changing one or more classes.
Thanks,
I would go with marking your business objects as [Serializable]. I think it should be a lot leaner than storing datatables/datasets.
The best way to make your classes serializable is to simply decorate them with [Serializable] I don't think you need anything else besides that.
If you use a load balancer with sticky sessions, I would actually go with LocalStateServer as it should perform faster than SqlServer
I think you can go for your point 2.
there is no magic/automated way to change all your classes to be serializable, either you use the attribute way or the interface way but in some classes you could need some fixes or changes depending on what are the property types.
apart from that everything should work smoothly once everything is Serializable and yes, you touch the web.config and all should work.
if some of those objects are non user specific but can be shared among users, a possible alternative could be appFabric, if you configure a cache cluster (which could consist in multiple machines), you can then save objects in that cache, but as I said before this depends on your application, are those objects absolutely user specific so MUST be in the session and not in a shared cache? have a look at this answer: AppFabric vs System.Runtime.Caching

Sharing ASP.NET State databases between multiple apps

Is it better for a collection of ASP.NET web apps to share the same session database, or should each one have its own?
If there is no significant difference, having a single database would be preferable due to easier maintenance.
Background
My team has an assortment of ASP.NET web apps, all written in either Monorail 1.1 or ASP.NET MVC 1.0. Each app currently uses a dedicated session state database. I'm working on adding a new site to that list, and am debating whether I should create another new session database, or just share an existing one with another app.
The original question was "Share the same Session Database". I see this as different from the Application's Database. ASP Session for all applications would be the same. You would not be modifying the Schema for any of the Session Tables, SP's etc... We host a number of applications, each with their own private Database for the aplication data, and a single shared Database for session.
I would vote for separation here.
I don't think you'll necessarily find that it's "easier maintenance" in the long run to stuff everything into one database. If every app is using the same table and database instance, you can't separate one application from the pool without duplicating the entire database. What if one app goes viral and needs to be moved to it's own server cluster?
For the amount of work it takes to copy a database to a new instance, you'll be separating the concerns of the applications, making it easier to debug them individually, more scalable and much more portable.

Communicating between ASP.NET applications on the same machine

I have a situation where information about a user is stored in the web application cache and when that information is updated in one application - I want to notify the other applications (running on the same machine) that the data should be removed from it's cache so it can be refreshed. Basically I need to keep cached data in sync across multiple asp.net applications.
I have started down the path of using a central web service to help coordinate the notifcations but it is turning out to be more complex than I think it needs to be.
Is there a way that one asp.net application can easily reach across to another on the same box to clear an item from the cache?
Is there a better way to achieve shared cached information than using the application cache?
I really want to create a way for apps to communicate in a loosely coupled way - I looked at nservice bus but the dependency on MSMQ scared me away - my client has had bad experiences with MSMQ and does not want to support an app that requires it.
Suggestions?
Michael
I agree with Hogan. Best is to use a shared database. I want to add to that that, when using SQL Server, you can use SQL Cache Dependency. This SQL Server mechanism allows notifications to applications in such a way that used caches can be invalided directly after a change is made to the data.
A shared database is probably going to cause you the least pain.
Edit
Note: ASP.NET allows you to make "cache clearing" triggers on SQL server changes. Should be a quick search in the cache examples on MSDN to find some examples. Thus when the user info stored in the cache changes in the DB the local cache copy will clear and be re-loaded from the DB.
There are commercial distributed caches available for .net other than Microsoft Velocity - NCache, Coherence, etc.
How about Velocity? It's a distributed cache that works between servers as well as between applications. It has PowerShell management and all sorts of documentation to get you going faster and be far more maintainable in the long-term.
What about COM/DCOM, using namespace System.Runtime.Remoting

Resources