重定向到页面时,会话变为空白 [英] Session is getting blank when redirecting to page

查看:477
本文介绍了重定向到页面时,会话变为空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,



我有以下情况。



我有一个登录页面和一个我的个人资料页面。



在登录页面加载事件中,我正在检查如果用户已通过身份验证,则会重定向到我的个人资料页面。如果用户未经过身份验证,则用户必须登录,然后重定向到我的个人资料页面。



现在第一次,用户登录系统然后我存储会话对象中的一些值,然后它重定向到我的个人资料页面,在这种情况下,所有会话都被填满。



现在假设您在浏览器中键入URL访问登录页面,然后检查页面加载事件中的身份验证代码,它会自动重定向到我的个人资料页面,但在这种情况下,所有会话都变为空白,在重定向之前,我检查会话值并且它们都在那时存在但在重定向后,它在我的个人资料页面中都是空白的。



如果我在这两种情况下执行相同的功能,怎么会发生这种情况?



谢谢

解决方案

1.检查会话到期时间

2.检查清除会话的所有操作。

我认为你需要这样的那个,任何未经验证的用户都不应该能够访问你的个人资料页面。这样,一个人应该被重定向到登录页面。



为此,有一个非常好的概念可用称为 FORMS AUTHENTICATION 。请参阅下面的链接



如何:实现简单表单身份验证 [ ^ ]



如果您使用会话,它将会在服务器端消耗一些内存,你必须在每个页面中实现它。



使用表单身份验证时,你只需要使用web.config文件就可以了完成。



如果您需要更多帮助,请告诉我。


Hello friends,

I have following scenario.

I have one Login page and one My profile page.

In login page load event, I am checking that if user is authenticated then it redirects to my profile page. If user is not authenticated then user should have to login and then it redirects to my profile page.

now first time, user log in to the system then I am storing some values in session object and then it redirect to my profile page, in this case all sessions are getting filled up.

Now suppose, you type the URL in browser to access login page then it check authentication code in page load event and it redirects automatically to my profile page but in this case, all sessions are getting blank, before redirecting, I check session values and they all are exist at that time but after redirecting, its all blank in my profile page.

How could this happened if I am executing same function in both situation?

Thanks

解决方案

1.Check the session expiration time
2.Check all the operation of clear session.


I think you need such that,any unauthenticated user should not be able to access your profile page.Doing so,one should be redirected to login page.

For this,there is very good concept available called FORMS AUTHENTICATION.Refer to link below

How to: Implement Simple Forms Authentication[^]

If you use session,it will consume some memory at server side and you have to implement it in every page.

While using forms authentication,you just have to work with web.config file and you are done.

Let me know if you need more help on this.


这篇关于重定向到页面时,会话变为空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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