 |
|
 |
Yes you can stop session timeouts. There is a easy way that does not require AJAX calls or other such methods. I have tested this method on an ASP.NET Data Entry page and left it up for 4 hours, clicked save, and all was well.
Dealing with Session Timeouts in ASP.NET was always a pain. I came across a method by Primary Objects that is simple to implement and will not only keep the session alive but will keep the worker process alive on the server as well.
http://snippets.surfthru.com/post/Stop-ASPNET-Session-Timeouts.aspx[^]
|
|
|
|
 |
|
 |
Hi,
in my application - when I traverse for sometime to various tabs - suddenly login,aspx page is displayed.
When I checked logs - but no debugger statement printed there..and no javascript alerts are seen.
So I verified web.config for timeout properties but couldnot find anything to be changed
<authentication mode="Forms">
<forms loginUrl="login.aspx" protection="All" timeout="600" slidingExpiration="true" >
</forms>
</authentication>
and
<sessionState mode="InProc" timeout="600" />
Thanks and regards,
- Ajay Kale
|
|
|
|
 |
|
 |
Hi
I have a query regarding redirection to Login page, which I am not being able to trace out.
When I click on any of the tab in my application (which internally loads a new aspx page) sometimes it
is redirected to Login.aspx, which is unexpected. Couldnot debug why this is happening even by javascript alerts and C# debugging statements.
Below is the view source piece from Login.aspx, just for clue
<form name="Form1" method="post" action="login.aspx?ReturnUrl=%2fValuations%2fToDoList.aspx" id="Form1">
Valuations is the dll of application and ToDoList.aspx is the tab page I clicked which should load, but suddenly Login.aspx page is displayed. I traced the complete solution project.
- in web.config
<authorization>
<deny users="?"/>
</authorization>
- -suddenly while traversing in the application it redirects to login.aspx including return url as stated earlier and also if we keep the application idle for 5-10 mins and clicks somewhere, still redirects....
- - we have also AjaxPro.dll for async calls.
- when the login.aspx page is not closed then, below logger statements are seen after 5 mins
-public Global()
{
_log4netLogger.Debug("Global:Global");
InitializeComponent();
}
- catch of Session_End (because System.Web.HttpContext.Current.Application["userPool"]; is null)
- Application_End
Can you please help me...?
- Ajay K
|
|
|
|
 |
|
|
 |
|
 |
This code works within Visual Studio but when deployed (run using IIS), the session times out. We have 2 webservers for load balancing.
I appreciate any response.
|
|
|
|
 |
|
 |
Hi,
I develop a lot of asp.net websites, and I came across this issue also, especially in combination with the concept of url-rewriting. The way I re-write the url's is done through regular expressions, and because I disabled the session (to work around the time-outs), the url was rewritten like crap. The SessionID kept putting itself inbetween my urls, so I disabled the session altogether in web.config like so:.
Then I rewrote my application to store all global (application) variables in a static class. Then we had the issue of logging in. So when logging in (which used to require SessionState in my application) I put the following code:
System.Web.Security.FormsAuthentication.SetAuthCookie(tbUSERNAME.Text, false);
Response.Redirect("~/Admin/Default.aspx");
And on top of the page which should be authenticated I put the following:
private string AuthenticatedUser = "";
protected void Page_Init(object sender, EventArgs e)
{
try
{
string temp = this.Page.User.Identity.Name;
AuthenticatedUser = temp;
}
catch
{
}
if (String.IsNullOrEmpty(AuthenticatedUser) == false)
{
}
}
Hope this is of any use to anyone. If you have questions, just ask!
|
|
|
|
 |
|
 |
This giving me a new idea, how to make a trigger with client side scripting before the session timeout..
So, i can use the session data before it clear/destroy to update the DB (IS_LOGIN)
IS_LOGIN is a flag, where it inform when the user login/not login.. to make sure the user cannot do double login from other location..
Hehe.. Once again Thanks...
|
|
|
|
 |
|
 |
I was wandering if it would be possible to create me a simple program to stop my online banking logging me out or do you know of such a program already in existence. Maybe just tell it to activate the browsers refresh button would do fine. I am not a programmer at all yet so i wouldn't be able to create this myself.
thank you so much in advance
jsmith07611@gmail.com
|
|
|
|
 |
|
 |
Your browser would have to reload the page occasionally since you do not have access to change the banks code. (A GreaseMonkey script code sort of rewrite the code I guess).
This extension should do the job
https://addons.mozilla.org/en-US/firefox/addon/115[^]
|
|
|
|
 |
|
 |
For those of you using ASP.NET 2.0 with MS AJAX, here is an update for you. Some of you probably don't know that AsyncPostBacks (those caused by UpdatePanels and what not) cause you to do a little more work when registering scripts via the Server-Side. Also, keep in mind that this WILL WORK even when you don't have a ScriptManager on the Page.
Just change the path to your "Reconnect.aspx" page (see the bold text below) to reflect your site structure. I use this script in my MasterPage and call it each time the Page Loads. Always register this script everytime the page loads, it's smart enough to handle AsyncPostBacks and that's what you want.
private void RegisterSessionKeepAlive()
{
try {
int timeoutWindow = 30; int timeout = (this.Session.Timeout * 60000) - (timeoutWindow * 1000);
string reconnectUrl = VirtualPathUtility.ToAbsolute("~/Common/SessionReconnect.aspx");
string startupScript = string.Format("window.setInterval('reconnectSession()', {0});\n", timeout); string scriptKey = "SessionReconnectScript";
string startupScriptKey = "SessionReconnectStartupScript";
ScriptManager sm = ScriptManager.GetCurrent(this.Page);
if (sm != null && sm.IsInAsyncPostBack)
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), startupScriptKey, startupScript, true);
else {
if (!Page.ClientScript.IsClientScriptBlockRegistered(this.Page.GetType(), scriptKey)) {
System.Text.StringBuilder script = new System.Text.StringBuilder();
script.Append("var reconnectCount = 0;\n"); script.Append("var reconnectMax = 5;\n"); script.Append("function reconnectSession(){\n");
script.Append("\treconnectCount++;\n");
script.Append("\tif (reconnectCount < reconnectMax){\n");
script.Append("\t\twindow.status = 'Session Refreshed ' + reconnectCount.toString() + ' time(s)';\n");
script.Append("\t\tvar img = new Image(1,1);\n");
script.AppendFormat("\t\timg.src = '{0}';\n", reconnectUrl);
script.Append("\t}\n");
script.Append("}\n");
Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), scriptKey, script.ToString(), true);
}
if (!Page.ClientScript.IsStartupScriptRegistered(this.Page.GetType(), startupScriptKey))
Page.ClientScript.RegisterStartupScript(this.Page.GetType(), startupScriptKey, startupScript, true);
}
}
catch (Exception) { throw; }
}
|
|
|
|
 |
|
 |
Tim
I got this to work but only after I wrapped the Javascript sections in
strScript = "<script type='text/javascript'>;"
.....
strScript += "</script>"
Prior to that it just printed the startupScript on my page
JohnG
To the brave and faithful all things are possible! Cardiff 2006
|
|
|
|
 |
|
 |
Are you sure you specified "true" as the last parameter of the "RegisterStartupScript / ScriptBlock" methods? The scripts components automatically add those "<script>" tags in there for you. Granted, I am running on ASP.NET 2.0 SP1.
|
|
|
|
 |
|
 |
You're right - I hadn't set the last param to True. I was translating your code into VB and didn't see the last parameter because the line was too long and I couldn't scroll across in IE7.
To the brave and faithful all things are possible! Cardiff 2006
|
|
|
|
 |
|
 |
For some reason my app times out after approximately five minutes even if I have set the session timeout to 20 minutes. Is there a performance hit or some other reason why I should not set the timeout to five minutes (or even one minute) and set the reconnectMax to a high value like 100?
thanks
Thomas
|
|
|
|
 |
|
 |
We're currently seeing this issue in another app (one I haven't added this feature to). I'm not sure why Sessions timeout like this (it could have something to do with the fact that ASP.NET does not renew the Session timeout until you have had some activity on the site after the timeout has reached it's half-way point). But I don't see a problem with your approach.
|
|
|
|
 |
|
 |
I can keep the session alive for approx. 17 minutes by setting the refresh-timing to one minute, which is fine. But as soon as it reaches 18-20 minutes, the session times out (the session timeout is 20 minutes). So the five minute issue seems be solved - thanks.
best regards
Thomas
|
|
|
|
 |
|
 |
As I see it you will add another window.setInterval for each asynchronous postback. My test shows that even if you register the script using the same key, the script will be rendered again and as a result add another interval.
A correct way could be to instead reset reconnectCount on each async postback.
|
|
|
|
 |
|
 |
I hadn't seen that before, but if you simply registered a "ScriptBlock" with the JavaScript in a function, and then just call the "setInterval" functions to turn on and off the AsyncPostBacks, that would work as well. That would cut down on the number of scripts getting registered.
|
|
|
|
 |
|
 |
For some reason the reconnect page still got cached at the client. I can see this with fiddler, I only see one request.
Setting the output cache didn't solve the problem. Therefore I did the following in the javascript and that worked:
Reconnect.aspx?count=' + count
|
|
|
|
 |
|
 |
In my opinion (and this is just my opinion) using an ajax call to keep the session alive would be a more elegant solution.
|
|
|
|
 |
|
 |
How to implement using ajax call?
thank you for considering.
|
|
|
|
 |
|
 |
Its the same, with this solution there's no xml request proxy and all that is very clean.
Regards,
Jorgebg
Diseño web
|
|
|
|
 |
|
 |
An how are you going to save cookies from ajax calls to the caller page?
|
|
|
|
 |
|
|
 |
|
 |
Hi,
I have an ASP.net page that takes over an hour and sometimes more to execute.
I have set the session timeout to 40 minutes and have the following java script to send mesg to server just to prevent timeout from occuring.
<script type="text/javascript" language="javascript">
function Reconnect(){
var img = new Image(1,1);
img.src = "New.aspx";
}
window.setInterval("Reconnect();", 600000); //Set to length required
</script>
After the page has been running for more 60 minutes, I get a Page Cannot Be Displayed error.
This error occurs in IE 6 , but the page executes without a problem in Firefox.
I would like to know what is actually causing the error and why is my script not working for IE.
Is it an IE setting that can be changed or something else?
Thanks
|
|
|
|
 |