English 中文(简体)
ASP. NET MVC 3.0 重新安排会议时间
原标题:ASP.NET MVC 3.0 Redirect on Session Variable Expire?

In my ASP.Net MVC 3.0 Application, I am accessing my Session variable allover the application. code

HttpContext.Session["CustomerID"]= customerID;

When any of the session variable is not available or null due to session time out, i would like to redirect the user to the login page.

How can i do it. because i am using Session variable allover the application i can t check the variables for null at each instance.

任何帮助都将受到高度赞赏。

增 编

最佳回答

我假定,一旦会议结束,你就希望做到这一点。 为此,你需要某种客户密码(javascript)在一定时间间隔内与服务器核对。

Create an action called IsServerExpired and have it return a json object containing a boolean value, and the redirect url.

Write a javascript function that checks back with the server and then do the redirect in javascript when the value returned is true.

问题回答

暂无回答




相关问题
Pass session data onto URL

I have some information that is set in the sessions, and I was wondering if it s possible to pass this info onto the URL for the view that uses this session data. I want this to be working in such a ...

Session Variables, Hidden Fields and Tables

Ok, would this work? When a user logins a session variable is created. Then using the session variable I am able to put into a hidden field the correct user s ID number. The hidden field is in a ...

php - transfer $_SESSION var s to local var s?

What is best practice with regards to using session variables? Is it best to just refer to them as session variables or is it better at the beginning of the script to transfer them to local variables ...

Get session variable value

After I set a session object, how can I access the value of the given object in my templates?

invalid sharepoint session objects

Ok I m new to SharePoint and ASP, so bear with me... I want to persist objects to the session array for maintaining stuff between postbacks. I enabled the session array in my web.config file, and ...

.NET HttpSessionState Case Insensitivity

.NET s HttpSessionState using an "InProc" store seems to treat session variable key values as case insensitive. For example: session["foo"] = 1; session["Foo"] = 2; Trace.Write(session["foo"]....

热门标签