如何处理身份验证/会话超时? [英] What to do with Authentication/Session Timeout?

查看:334
本文介绍了如何处理身份验证/会话超时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个登录页面,在通过Oracle DB对其进行身份验证之后,我将把b / b
存储到用户信息中会话。但是,当发生会话

超时时,所有用户信息都将丢失。


我已经尝试过Reponse.Redirect回拨给我的登录页面,每当我检测到会话为空时,我都会收到异常,但是我一直在说#

重定向不是页面回调中的所有内容。


任何人都可以给我一些指针我应该如何解决这个问题。


谢谢,

Simon

解决方案

" Simon Says" < si ****** @ gmail.com写信息

新闻:eq ************** @ TK2MSFTNGP04.phx.gbl ...


我有一个登录页面,在通过Oracle DB对其进行身份验证之后,我会将用户信息存储到会话中。但是,当发生

会话超时时,所有用户信息都将丢失。


我已经尝试过Reponse.Redirect回拨给我的登录页面,每当我检测到会话为空时,我都会收到异常,但是我一直在说#

重定向不是页面回调中的所有内容。


谁能给我一些指针我应该如何处理这个问题。



您是否尝试过Server.Transfer而不是Response.Redirect ...?


是。尝试过,我仍然得到相同的错误信息。


我的代码中有很多客户端javascripting。我在.vb代码的Page_Load事件中放置了我的重定向调用

。当javascript代码触发重定向
时,我会有错误。但是,当我执行一个服务器控件

事件时,就像点击一个回发按钮一样,我的Redirect工作正常。


--Simon

" Mark Rae" < ma ** @ markNOSPAMrae.com写信息

新闻:例如************** @ TK2MSFTNGP02.phx.gbl ...
< blockquote class =post_quotes>
" Simon Says" < si ****** @ gmail.com写信息

新闻:eq ************** @ TK2MSFTNGP04.phx.gbl ...


>我有一个登录页面,在通过Oracle DB对其进行身份验证后,我将把用户信息存储到会话中。但是,当会话超时发生时,所有用户信息都将丢失。

我已经尝试过Reponse.Redirect回拨到我的登录页面每当我检测到会话为空,但我一直得到例外说明
...不是全部重定向页面回调。

任何人都可以给我一些指针我应该如何处理这个问题问题。



您是否尝试过Server.Transfer而不是Response.Redirect ...?


" Simon Says" < si ****** @ gmail.com写信息

新闻:eS ************** @ TK2MSFTNGP04.phx.gbl ...


我的代码中有很多客户端javascripting。



OK。


我将重定向调用放在.vb代码的Page_Load事件中。



啊 - 这可能解释它...你的页面是否有其他的Page事件(例如

Page_Init,Page_Prerender,Page_Unload等)。 ..


我在Response.Redirect上遇到过类似的问题 - 例如如果您在Page_Init方法中放置了

Response.Redirect,则Page_Load方法仍然会触发
,但如果您使用Server.Transfer,则会发生转移

立即...


当javascript代码触发重定向时,我将收到错误消息。



???你的意思是什么 - 你的客户端JavaScript怎么对Response.Redirect进行

调用...?


一般来说,我做的都是这个东西在基类中,所有页面都是继承,或者是MasterPage(s)继承的:


公共类BaseMasterEvents:Page

{

public BaseMasterEvents()

{

this.PreInit + = new EventHandler(BaseMaster_PreInit);

}


private void BaseMaster_PreInit(object sender,EventArgs e)

{

if(Session。 IsNewSession)

{

Server.Transfer("〜/ sessionTimedOut.htm",false);

}

}

}


Hi,

I''ve a login page in which after authenticating it via the Oracle DB, I will
stored the user information into the Session. However, when the Session
timeout occurs, all of the user information will be lost.

I''ve tried doing a Reponse.Redirect call back to my login page whenever I
detected the Session is null, but I kept getting the exception saying "...
Redirect not all in Page Callback".

Could anyone give me some pointer how I should approach this issue.

Thanks,
Simon

解决方案

"Simon Says" <si******@gmail.comwrote in message
news:eq**************@TK2MSFTNGP04.phx.gbl...

I''ve a login page in which after authenticating it via the Oracle DB, I
will stored the user information into the Session. However, when the
Session timeout occurs, all of the user information will be lost.

I''ve tried doing a Reponse.Redirect call back to my login page whenever I
detected the Session is null, but I kept getting the exception saying "...
Redirect not all in Page Callback".

Could anyone give me some pointer how I should approach this issue.

Have you tried Server.Transfer instead of Response.Redirect...?


Yes. Tried that and am still getting the same error message.

I''ve alot of client side javascripting in my code. I placed my Redirect call
in the Page_Load event in the .vb code. When the javascript code triggered
the Redirect, I''ll have the error. But, when I execute a server control
event, like a clicking a button that do a postback, my Redirect works fine.

--Simon
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:eg**************@TK2MSFTNGP02.phx.gbl...

"Simon Says" <si******@gmail.comwrote in message
news:eq**************@TK2MSFTNGP04.phx.gbl...

>I''ve a login page in which after authenticating it via the Oracle DB, I
will stored the user information into the Session. However, when the
Session timeout occurs, all of the user information will be lost.

I''ve tried doing a Reponse.Redirect call back to my login page whenever I
detected the Session is null, but I kept getting the exception saying
"... Redirect not all in Page Callback".

Could anyone give me some pointer how I should approach this issue.


Have you tried Server.Transfer instead of Response.Redirect...?



"Simon Says" <si******@gmail.comwrote in message
news:eS**************@TK2MSFTNGP04.phx.gbl...

I''ve alot of client side javascripting in my code.

OK.

I placed my Redirect call in the Page_Load event in the .vb code.

Ah - that might explain it...Does your page have other Page events (e.g.
Page_Init, Page_Prerender, Page_Unload etc)...

I''ve encountered similar issues with Response.Redirect - e.g. if you place
Response.Redirect in your Page_Init method, the Page_Load method will still
fire, but if you use Server.Transfer, the transfer will happen
immediately...

When the javascript code triggered the Redirect, I''ll have the error.

??? What do you mean exactly - how is your client-side JavaScript making a
call to Response.Redirect...?

Generally speaking, I do all of this stuff in a base class which all pages
inherit, or which the MasterPage(s) inherit(s):

public class BaseMasterEvents : Page
{
public BaseMasterEvents()
{
this.PreInit += new EventHandler(BaseMaster_PreInit);
}

private void BaseMaster_PreInit(object sender, EventArgs e)
{
if (Session.IsNewSession)
{
Server.Transfer("~/sessionTimedOut.htm", false);
}
}
}


这篇关于如何处理身份验证/会话超时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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