views:

33

answers:

2

I have page in my asp.net mvc website with a flash app on it, and the user can stay on that page for hours, but his auth cookie/session is going to expire, so I'm thinking to create a PingController and to call it using jquery $.post each 20 minutes.

is this a good idea ?
or there is something better ?

+2  A: 

Why you don't increase auth cookie timeout? Like so (if you are using forms authentication):

<authentication mode="Forms">
  <forms loginUrl="~/Login" timeout="600" name="Something"/>
</authentication>

Cheers!

rrejc
+1  A: 

You can actually do this using jquery and setInterval. In the setInterval, you can give a callback and the interval time. In the callback, you can post to the server to keep it alive. For more information, see the blog for asp.net MVC at http://www.dotnetcurry.com/ShowArticle.aspx?ID=453&amp;AspxAutoDetectCookieSupport=1

mohang
@mohang that's exactly what I think to do, with the exception that I'm doing this in mvc and I don't know if it makes sense to use HttpHandler instead of a controller
Omu
It is quite simple and fast to try it using controller action and update some session data. I have not tried this, though I strongly believe it works. If it does not, you can always fallback on HTTPHandler, you can check the example I provided to add a handler the fastest way. While trying, set the session duration to the least so that you can test it faster.
mohang