我是IntraWeb的新手,有一个问题。为了实现登录表单,我将数据集存储在Usersession中。但是,当涉及到访问数据集时,我得到一个访问冲突错误。我发现,Useresession不是创建的。现在我有点困惑了,因为在Intraweb纪录片中说,用户会话是由ServerController自动创建的。
我像这样访问(各自想要)数据集UserSession.Dataset.open;
我使用Rad Studio XE5中包含的IntraWeb试用版。这可能是问题所在吗?如果这不是问题所在,我如何手动创建Usersession?
非常感谢
编辑13.4.16
问题出在我使用的评估版本。安装完整版后,我的问题就消失了。他们通过添加另一个参数更改了Usersession.create过程。因此,如果你有同样的问题,请确保使用实际版本:感谢所有的回复
发布于 2016-04-08 16:56:51
你需要在会话中创建'data‘
procedure TIWServerController.IWServerControllerBaseNewSession(
ASession: TIWApplication; var VMainForm: TIWAppForm);
begin
ASession.Data := TUserSession.Create;
end;请注意,在此示例中
TUserSession
是用户定义的类
type
TUserSession = class
public
UserCount: Integer;
end;请看本教程,其中解释了如何在IW - http://etutorials.org/Programming/mastering+delphi+7/Part+IV+Delphi+the+Internet+and+a+.NET+Preview/Chapter+21+Web+Programming+with+IntraWeb/Building+IntraWeb+Applications/中进行会话管理
或者参考atozed提供的technical documentation。
发布于 2016-04-10 13:18:47
我试着只添加一个评论,显然我需要更多的点数。如果你进入RBA给出的响应,答案就会找到,但这里是简短的形式:
IW确实会自动创建和管理用户会话。然而,TIWUserSession只是你的一部分。为了在会话中包含您自己的数据,需要对TIWUserSession执行.Create操作,并将其添加为会话的.Data。在IWServerControllerBaseNewSession中,使用以下命令执行此操作:
ASession.Data := TIWUserSession.Create(nil, ASession);请注意,该过程的ASession参数是由IW管理的会话。
要访问您的TIWUserSession,请在ServerController中创建一个过程:
function UserSession: TIWUserSession;
begin
Result := TIWUserSession(WebApplication.Data);
end;在接口部分公开该过程。
丹
发布于 2016-04-12 11:28:01
我突然想到,我们可能“解决了错误的问题”。
您指出这是在实现登录表单时发生的。您还指出WServerControllerBaseNewSession()中的中断集未命中。
在ServerController中,是否将"AuthBeforeNewSession“设置为True?如果是,则将其设置为False,并查看行为是否发生更改。
丹
https://stackoverflow.com/questions/36494730
复制相似问题