分享与最好的办法QUOT;会话状态" 2 .NET应用程序之间的数据类型 [英] best way to share "session state" type data between two .net applications

查看:187
本文介绍了分享与最好的办法QUOT;会话状态" 2 .NET应用程序之间的数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个Web应用程序,展开,取出小,即添加任何新功能,只是制造出来的同一个项目的一部分,但是现在我们想创建新项目为这些说插件...

we have a web application that, started out small, any new features that were added on, were just made as part of the same project, however now we would like to create new projects for these said addons...

我们创建了一个新的项目,它inharits主体工程在Global.asax,并且还访问了主体工程的web.config文件就好了,但是,在全球ASAX code有会检查数据的完整性,看看如果用户登录..这就是我们得到的问题..该用户登录,而是出于说明该网站的错误,他们ARNT登录,因为插件项目不能访问会话的用户ID是由主项目进行设置。

we created a new project, it inharits the global.asax of the main project, and also accesses the web.config of the main project just fine, however, in the global asax code there's session checking for data integrity, to see if the user is logged in.. this is where we are getting issues.. the user is logged in, but the site errors out stating that they arnt logged in, because the addon project cannot access the session user id that is set by the main project.

目前,我们不使用会话状态服务器或SQL状态服务器,我们要避免它,以避免任何麻烦一些上了年纪的code。

currently we are not using a session state server, or sql state server, and we would like to avoid it to avoid any headaches for some of the older code.

也是我们不希望去互斥路线..要远离窗户的编码,如果我们能和...

also we dont want to go the route of mutexes.. want to stay away from windows coding if we can as well...

现场与会议发生了什么概要: 用户与ASP code登录(.NET 1.1 code) 用户进行身份验证,并成功登录,发送一个GUID该用户到数据库,主体工程(.NET 2.0 $ C $三)抓住该GUID,抓起用户数据并存储在会话的用户ID。 任何网页,需要知道用户是谁,得到它从session(用户id)

site outline of what happens with the session: user logs in with asp code ( .net 1.1 code) user is authenticated and successfully logged in, sends a guid for that user to a database, the main project( .net 2.0 code) grabs that guid, grabs the users data and stores the user id in the session. any page that requires knowing who the user is, gets it from the session("userid")

这样: 我们创建另一个项目inheirits在Global.asax,可以访问web.config中 - 完成

so: we create another project that inheirits the global.asax, can access the web.config - DONE!

我们想要做的在此之上: 这个新的项目包含一个网页(从主体工程插件功能)有这个页面访问会话(用户id)是从主项目设置。 - 不知道如何做到这一点?

what we want to do on top of this: have this new project contain a page (addon feature from the main project) have this page access the session("userid") that is set from the main project. - NOT SURE HOW TO DO THIS...

推荐答案

我会preFIX我的建议通过说的最佳的方式来保持的复杂性降至最低将是使用状态服务器。这是一个问题,他们的目的是解决

I would prefix my suggestion by saying that the best way to keep complexity to a minimum would be to use a state server. This is a problem they are designed to solve.

这是所说的......

That having been said...

由于两个应用程序必须在不同的过程中运行(因为它们是在不同的运行版本),它们不能直接共享数据

Since the two applications have to run in different processes (as they are in different runtime versions), they cannot directly share the data.

一种选择是使用Web服务或远程。你可以有一个CustomSession对象,它存储所有会话的数据,并确定每一个通过的的Guid 。你可以追踪使用GUID-CustomSession在应用上创建了所有现有的会话,并通过查询字符串向应用B应用程序B通过使用GUID可以查询应用程序A具有GUID,可以通过Web服务或远程处理,并得到相应的CustomSession对象返回。你可以反向,以及这样做。

One option could be to use Web Services or Remoting. You could have a CustomSession object which stores all a session's data, and identify each one by a Guid. You could track all your existing sessions created in Application A by Guid-CustomSession, and pass the Guid via querystring to Application B. Application B can query Application A with the Guid, either via Web Service or Remoting, and get the corresponding CustomSession object back. You could do the same in reverse as well.

这里唯一的问题是,你必须确保从应用程序中的一个页面中的App B就移动到页面或反之亦然,当GUID是始终提供的URL。该应用程序可以随时检查会话不存在,回落到使用GUID来看看其他应用程序有一个会议。

The only issue here is you have to make sure the Guid is always provided in the URL when moving from a page in App A to a page in App B or vice-versa. The application can always check if session does not exist, to fall back to using the Guid to see if the other app has a session.

千万要小心一些。NET数据结构(不是很多)被序列化不同的.NET 1.1和2.0,因此在共享远程或Web服务的对象时,你可能需要考虑这一点。

Do beware that some .NET data structures (not many) are serialized differently between .NET 1.1 and 2.0, so when sharing the objects over remoting or web services, you may need to account for that.

这篇关于分享与最好的办法QUOT;会话状态" 2 .NET应用程序之间的数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆