Results 1 to 8 of 8

Thread: [RESOLVED] asp.NET MVC1 - Call controller action on timer tick

  1. #1

    Thread Starter
    Fanatic Member stlaural's Avatar
    Join Date
    Sep 2007
    Location
    Quebec, Canada
    Posts
    683

    Resolved [RESOLVED] asp.NET MVC1 - Call controller action on timer tick

    Hi all,
    I'm currently working on an ASP.NET MVC1 web application and we have a page, a timesheet, that the user use to enter his the time he passed working on his tasks. The problem we are having right now is that the session's timeout is 20min and we don't want to change it. With the timesheet page though, a lot of users simply open it, start entering some time entries, go do someting else and then come back etc... during that their session timed out and as they didn't saved, they lost their entries.

    I would like to implement an auto-save feature, like saving the timesheet no matter what, every 2 minutes.
    Edit : Like the auto-save that you get when you are editing a document on google docs.

    So I'm trying to find the best approach. We already have a controller action that validates and save the timesheet data when the user clicks the save button (using Html.ActionLink) so I would like to call the same action but from a timer_tick event handler if possible. Right now the only way I can think of is using Ajax to call the proper controller action, but I just don't like it, I find it hard to read and maintain for the next guy who will have to work on that. I would have like to simply had a timer and call the controller's action from the behind code I haven't been able to figure out how yet.

    Edit : The action that is currently called does some validations and returns a view. Also, the parameters that needs to be sent to the Action are the current Dataview and an "action" which comes from an enum, so I'm not sure that it is accessible from JQuery. In other words, If I don't find a work around solution I guess I'll have good refactoring to do.

    So I'm basically taking any suggestion on how to implement the auto-save.

    Thanks
    Last edited by stlaural; Jan 31st, 2011 at 10:19 AM. Reason: added details.
    Alex
    .NET developer
    "No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)

    Things to consider before posting.
    Don't forget to rate the posts if they helped and mark thread as resolved when they are.


    .Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
    My fresh new blog : writingthecode, even if I don't post much.

    System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: asp.NET MVC1 - Call controller action on timer tick

    Hello,

    You have posted your question in the ASP.Net forum, but we actually have an ASP.Net MVC forum as well.

    I am going to move your thread there, as this is where you question belongs.

    Thanks

    Gary

  3. #3

    Thread Starter
    Fanatic Member stlaural's Avatar
    Join Date
    Sep 2007
    Location
    Quebec, Canada
    Posts
    683

    Re: asp.NET MVC1 - Call controller action on timer tick

    Thanks Gary, can't believe I missed it, it's just 2 positions bellow the ASP.Net section. :S
    Alex
    .NET developer
    "No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)

    Things to consider before posting.
    Don't forget to rate the posts if they helped and mark thread as resolved when they are.


    .Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
    My fresh new blog : writingthecode, even if I don't post much.

    System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: asp.NET MVC1 - Call controller action on timer tick

    Ha ha

    It hasn't been around too long, so not common knowledge yet.

    Gary

  5. #5

    Thread Starter
    Fanatic Member stlaural's Avatar
    Join Date
    Sep 2007
    Location
    Quebec, Canada
    Posts
    683

    Re: asp.NET MVC1 - Call controller action on timer tick

    Well I finally found a solution. I used the jQuery Form Plugin, available here. It basically allows you to submit an existing html form, which I really needed as I am using Asp.Net MVC1 and the action I am calling rebuilds the viewdata from a table that is in the form. And I simply setted an interval that suits my need in order to call that action regularly.
    Alex
    .NET developer
    "No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)

    Things to consider before posting.
    Don't forget to rate the posts if they helped and mark thread as resolved when they are.


    .Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
    My fresh new blog : writingthecode, even if I don't post much.

    System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] asp.NET MVC1 - Call controller action on timer tick

    Hello,

    Are you tied to MVC 1? I was at a presentation the other weekend about MVC 3.0, and it seems like things have moved on quite a bit. Might be worth looking to move up.

    Gary

  7. #7

    Thread Starter
    Fanatic Member stlaural's Avatar
    Join Date
    Sep 2007
    Location
    Quebec, Canada
    Posts
    683

    Re: [RESOLVED] asp.NET MVC1 - Call controller action on timer tick

    Yeah, for this application I'm currently tied to MVC1 as we are only doing small improvements and bug fixes on it. We are supposed to start developing the next version soon though, this one will use MVC2 or even 3 if we're lucky and if its available at that moment.
    Alex
    .NET developer
    "No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)

    Things to consider before posting.
    Don't forget to rate the posts if they helped and mark thread as resolved when they are.


    .Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
    My fresh new blog : writingthecode, even if I don't post much.

    System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0

  8. #8
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] asp.NET MVC1 - Call controller action on timer tick

    Ah, fair enough.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width