会话过期时出错 [英] Error when the session expires
问题描述
我已经应用于目录结构如下:
[IMG] http://i971.photobucket.com/albums/ae198/haocaocu/Errors/struct_application_zpsrr9ja26q.png [/ IMG]
页面iDOC.master我使用iframe
I have applied to the directory structure as follows:
[IMG]http://i971.photobucket.com/albums/ae198/haocaocu/Errors/struct_application_zpsrr9ja26q.png[/IMG]
Page iDOC.master I use iframe
<iframe id="ifrmContent" frameborder="0" name="ifrmContent" width="100%" src="Template/Default.aspx"
scrolling="auto"></iframe>
<script language="javascript" type="text/javascript">
var frame = document.getElementById('ifrmContent');
frame.height = screen.height - 130;
</script>
当我访问某个页面时,我检查的每个会话如下:
When I visit a page but every session I checked as follows:
if (Session["UserName"] == null)
{
Response.Redirect("~/Login.aspx");
}
else
但如图所示:
[IMG] http://i971.photobucket。 com / albums / ae198 / haocaocu / Errors / session_expire_zpsw5652yoy.png [/ IMG]
如果我从这里登录,它会出现:
[IMG] http:// i971.photobucket.com/albums/ae198/haocaocu/Errors/double_menu_zpswlgji2cw.png [/ IMG]
谁知道如何抛出login.aspx帮助我。谢谢
but it appears as shown:
[IMG]http://i971.photobucket.com/albums/ae198/haocaocu/Errors/session_expire_zpsw5652yoy.png[/IMG]
if I log in from this, it appears:
[IMG]http://i971.photobucket.com/albums/ae198/haocaocu/Errors/double_menu_zpswlgji2cw.png[/IMG]
Who knows how to get dished out the "login.aspx" help me with. Thank you
推荐答案
hi
您在iframe中使用会话但会话是相对于用户和网站,而不是页面
或者,您可以将查询字符串上的值传递给iframe。我不是这个的粉丝,因为这意味着用户可以篡改变量。相反,我想做的是生成一个随机密钥(guid对此有用),使用它作为Session密钥来存储变量,然后通过查询字符串传递密钥 - 仍然不是万无一失,但它会混淆事物(用户无法篡改变量值),并且它可以防止对源代码中的任何键进行硬编码(因为不同的页面需要知道相同的会话密钥)。
hi
you use session in iframe but Session is relative to the user and site, not the page
Alternatively, you could just pass the value on the querystring to the iframe. I am not a fan of this though as it means the user can tamper with the variable. Instead what i like to do is generate a random key (guids are good for this), use that as the Session key to store the variable, and then pass the key through on the querystring - still not foolproof, but it obfuscates things (the user cannot tamper with the variable value), and it prevents hardcoding of any keys in to your source code (as different pages need to know the same Session key).
这篇关于会话过期时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!