Best way to share session state data between two .net applications

We have a web application that started with small, any new features that were added, was made only as part of the same project, however now we would like to create new projects for these mentioned add-ons ...

we created a new project, it fits global.asax into the main project, and also just accesses the web.config of the main project, however there is a data integrity check session in the asax global code to see if the user is logged in .. this is where we get problems .. the user is logged in, but the site errors saying that they are logged in because the add-on project cannot access the user ID of the session that is installed on the main project.

We currently do not use a session state server or sql state server, and we would like to avoid it in order to avoid any headaches for any old code.

Also, we don’t want to go the way of mutexes .. want to stay away from window coding if we can ...

sketches of the site about what happens with the session: the user logs in with the asp code (.net 1.1 code), the user authenticates and logs in successfully, sends the manual for this user to the database, the main project (.net 2.0 code) captures this manual, Captures user data and stores the user ID in the session. any page that needs to know who the user is is getting it from the session ("userid")

like this: we are creating another project that suits global.asax, can access web.config - DONE!

what we want to do on top of this: if this new project contains a page (add-on function from the main project), this page has access to the session ("userid") that is set from the main project. - NOT SURE AS THIS ...

+3
session-state
source share
6 answers

I would prefer my suggestion, saying that the best way to minimize complexity is to use a public server . This is a problem that they decided to solve.

That was said ...

Since two applications must run in different processes (since they are in different versions of execution), they cannot directly exchange data.

One option might be to use web services or remoting . You may have a CustomSession object that stores all session data and identifies them by Guid . You can track all existing sessions created in application A using Guid-CustomSession, and transfer Guid via querystring to application B. Application B can request application A using Guid, either through a web service or through Remoting, and return the corresponding CustomSession object back, you can do the same in reverse order.

The only problem here is that you need to make sure that Guid is always specified in the URL when navigating from a page in Appendix A to a page in Appendix B or vice versa. An application can always check if a session exists, return to using Guid to find out if another application has a session.

Beware that some .NET data structures (not many) are serialized differently between .NET 1.1 and 2.0, so when sharing objects through remote or web services, you may need to consider this.

+3
source share

I know that you said you want to stay away from Session State Server ....

But I still think this is the best option. Especially if you plan to use more data than just the login ID for future scalability and maintainability. In addition, sharing login data is safer through the session state server than storing it on the client side through query strings, etc.

But then again, no matter what you do to share the session data, just like the other β€œRex M” poster, you need to be careful about what session data you share and that it needs to be serialized -able.

+2
source share

Using web services or deletions is similar to a session state server, except you must implement it yourself β€” probably not worth the effort.

If you are going to do it yourself, there is another problem that was not mentioned before: session timeout. You will need to make sure that both processes have the same idea about when the last session was used. If you do not do it right (and I came across this), you run the risk of getting into a state in which you seem to have entered one part of the application, but not the other.

+2
source share

You can use cookies to store your UserID. Both applications 1.1 and 2.0 can access it without any problems.

0
source share

Rex M: we are trying to exchange session data between the same versions of .net .. both are running .net 3.5, (works on the .net 2.0 platform), we already have code for xfer login data in environment 2.0.

we have the main project, but we want to add it using modules, we just tried it, if you add another .net web application, do not use namespaces and configure the session state server, configure your references and then compile, everything will add .

both applications (those with which they tried to exchange session data) work under framework 2.0, as in the same application pool, and with the same machine key, and with server status information running on the same machine, only from different folders ( however, share the same parent folder)

is there anything we can do to make this work?

(without using sql state server).

0
source share

You can use one or more encrypted query string variables that must pass when navigating between two web applications so that you can query and retrieve important session variables in two web applications. This is the easiest way.

0
source share

All Articles