How to share session variables in two different web applications? - asp.net

I have two different web applications: Phase I and Phase II.
Phase II has a dependancy on phase I for some session values.
I want to run these two applications with sharing session variables.
I don't want to use state server to store session.
I have used inproc session and I want to share this session together.
How do I achieve this?

you cant share the session between 2 apps with in-proc sessions because in-proc session runs within the context of an application. you can share the session only by taking it out of the application's context which is possible only with out-proc session mode.

Take a look into this LINK i guess it might help you setting things up.

Related

Application restart state management

Our asp.net web application restarts randomly and kicks off users while they are filling a big batch process form.
- the users have to re logging and fill everything afresh
- so keeping in mind that the application/session restarts randomly - which is the most appropriate technology to use for state management - session state (with MS-SQ L server) or asp.net cache ?
You need to configure something other than InProc for your Asp.Net session state provider. What you use depends on how durable the session data needs to be. The session state service is fine but if it does down it will still affect your application like InProc does today. Using a database is the most durable method, although this costs some performance.
You'll have to try and test which one is most appropriate for your needs.
You might also want to figure out why your app is crashing and fix it. I'm assuming its not a scheduled recycle as you said it was random. Recycling is really a Band-Aid for a badly behaving application.

How can the session state still be available when the AppFabric is crashed?

I'm using AppFabric as the session state provider for ASP.NET, and I'm thinking of a solution of HA. I find when the AppFabric is crashed, the entire web application will be affected.
Can I have a solution to let ASP.NET routes to use in-proc session to make more HA when the AppFabric is crashed?
Thanks in advance.
If you have just one server then switching to inproc sessions might make sense but if you have multiple servers and you're not using sticky routing (which doesn't make sense if your sessions were distributed) then only its going to benefit you.
Although I don't think there is any out of the box way of doing this but in principle it should be possible for you to write a session provider that switches from appfabric to inproc session and somehow signals your load balancer to resort to sticky sessions.
However you should note that if you have multiple servers in your app fabric cache then likelihood of all of them going down at once is very low so I would not even implement any over engineered solution.

Application variable across load balanced servers (ASP.Net)

We have a website that runs on two load balanced servers. We used the ASP.Net Application variable to make application state "online/ offline", or for some important messages across the application,
So when i try update a application variable its available on one server but not on other.
How i can manage a application variable across load balanced servers.
What may I use? Of course keeping it as simple as possible.
Are you using sticky sessions? How often does the data change? Is application cache even necessary?
One option: You can have each webserver store (and manage, refresh, invalidate) its own application cache. But then you run the chance of storing different copies.
Another option: distributed cache such as memcached or ncache or something else.
Another option: read/write the data out to a shared disk.
Store that information in a database that all servers have access to and access information from.

Retrieving active session information from IIS 7

I'm running several ASP.NET web sites with InProc session state and I would like to retrieve the number of active sessions per web site and hopefully any details around each session (eg client connection details).
My end goal is to be able to see who is connected to the web site so that I can notify them when deploying an update.
Is there any way to do this in .NET without resorting to SQL session state? I looked at Microsoft.Web.Administration but couldn't find a way to do it. And the "Sessions Active" performance counter in perfmon just gives the total sessions for the whole server (as well as not giving any metadata about the sessions).
EDIT: In my tests with performance counters I tested with total Sessions Active when I should have tested with the instance of Sessions Active for my web site. This gets me a little closer but I'd still like to actually retrieve the session information for the web site if possible.
Session is a concept, not an actuality. You can use the asp.net global.asax pseudo events for session start/end to track this concept but it will still only be an approximation. I think your best bet is to flip on your "maintenance in progress" flag and put something in the request pipeline that handles it for all incoming requests.
Not sure how/what you would do with this but I think you're going to be rolling some custom code here.

How to pass Session from one Application to another?

I am having 2 applications Suppose A and B. I am having a webpage in Application A where i am Setting the Session and in Application B i want to retrieve that session.How can i do that with out using DB?
Sessions are application specific and I don't believe you can share data between two applications via the session. You will need to pass the data through some other medium. You could serialize it and pass it via a POST parameter. You may also be able to use a cookie. If it is really small data, you could just pass it in the GET parameters of the query string.
I agree with NYSystemsAnalyst - and here's a FAQ on how to transfer session from a classic ASP app to ASP.NET. The code can nearly be copied to do the same thing in this case.
http://www.tek-tips.com/faqs.cfm?fid=2943
When you say without using a Database I guess you mean without using a third party database. There is no way around the fact you need to store and retrieve data while protecting against simultaneous access of underlying data structures causing problems, and this pretty much makes it a database. You could implement something simple by allocating some shared memory and using semaphores to protect access to it. Also you could have app A inform app B of changes to session state and have app B track these. This communication could be done over a named pipe between the apps. What OS are you targeting?
How are you Identifying you user between the applications?
What do you need in the session?
Not sure, but a web-service or wcf that passes the session variables back and forth for a given username || id?
( maybe not the session exactly but a object you could used to build/populate the session on both applications... )
User start session in App A, just before they move to App B store a small version of the session variables needed in cache with high priority but short expiry( this is what the web service would look for).
User stars session in App B, App B calls web service to see if user was in App A... if so get variables needed for App B?
No DBs, but you will need to do some work...
And not even sure this will solve what you looking for?
Used something kind of like this to talk from Admin servers on Production servers...
But I wasn't passing the session itself...
Good Luck

Resources