...如何在登录页面上显示会话过期错误消息。 [英] ...how to display an session expires error message on login page.

查看:404
本文介绍了...如何在登录页面上显示会话过期错误消息。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个完美的asp.net Web应用程序。我想稍微调整一下。我已经特定了我的会议。因此,会话到期后,用户将被重定向到登录页面。我想做的是告诉他们为什么他们被重定向再次登录(即会话)。我如何实现它。注意。如果第一次访问登录页面,则错误消息不可见。只有在会话结束时加载页面才会显示它。



我尝试过的事情:



除了在会话到期时将用户重定向到登录页面之外,现在还不能想到任何事情

I have a perfectly working asp.net web application. i want to tweak things a little bit. i have given a specific to my session. Hence, users are redirected to login page after session expires. What i want to do though, is to tell them why they have been redirected to login again(i.e session out). How do i achieve it. Note. if the login page is visited for the first time, the error message is invisible. it only becomes visible when the page is loaded as a result of session time out.

What I have tried:

Cant think of any for now apart from redirecting users to login page when session expires

推荐答案

没有万无一失的做法这是因为Web是无状态的,但您可以检查http referer属性以查看该请求是否已从其他页面发起。说实话,虽然我不会打扰。人们习惯在登录过期时被转储到登录屏幕。我更倾向于花费精力使用cookie来管理身份验证,因此他们的身份验证可以持续到会话之外,只有在他们选择注销或关闭浏览器时才会结束。
There's no foolproof way of doing this as the web is stateless, but you could check the http referer property to see if the request has been instigated from another page. To be honest though I just wouldn't bother. People are used to being dumped to a login screen when their login expires. I'd be more inclined to spend the effort using cookies to manage authentication so their authentication can last beyond the session and only ends when they choose to logout or close their browser.


,同时重定向添加一个查询字符串到网址。

while redirection add a query string to the url.
Response.Redirect("Utility.aspx?SomeKey=1");



并检查登录页面中的查询字符串 page_load 事件,根据您应显示/隐藏消息的价值




and check for the query string in the login page page_load event , based on the value you shall show/hide the message

protected void Page_Load(object sender, EventArgs e)
        {
            lblMessage.Visible = false;
            var value = Request.QueryString["SomeKey"];
            if (value != null)
                lblMessage.Visible = true


这篇关于...如何在登录页面上显示会话过期错误消息。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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