0

I have a form following the following resemblance...

@using (Html.BeginForm())
{
    @* Model elements go here *@
    <input type="submit" value="Save" />
}

and the following methods for this View, which we will just call 'Test'

public ActionResult Test()
{
    return View();
}

[HttpPost]
public ActionResult Test(ModelObj m)
{
    try{
        //do save logic with ModelObj entity
    }
    catch(Exception ex){
        //Log error - send e-mail to self and display 'save failed' msg to front end user
    }
    return View(m);
}

This code functions as expected when loading up the page and running it immediately, but other users (I cannot recreate the issue myself) are complaining that on longer wait times (leaving the page idle for over 10 minutes), on 'Save' click, the page does a postback (page flashes and reloads) but the data has not been saved.

I added the error logging in the try/catch to try to figure out the issue, but am receiving no error emails, and the users are not seeing the front end 'save failed' message provided by the catch block.

I can only imagine that this is a session issue - but I have eliminated all of my own uses of Session variables on this page and am wondering if MVC has it's own timeout period for a View (where it just tosses away all of the model information). If so, is there a way to increase this? Any other possibilities I should be looking for?

tereško
  • 58,060
  • 25
  • 98
  • 150
sebe
  • 139
  • 1
  • 10
  • Doesn't IIS control this? – Big Daddy Aug 28 '15 at 15:17
  • Looks like the default is 110 seconds: http://stackoverflow.com/questions/579523/how-do-i-set-the-request-timeout-for-one-controller-action-in-an-asp-net-mvc-app In any case I don't think this is your issue I think that it's possible that your logic behaves differently for different users. Pehaps a validation issue also? – Marko Aug 28 '15 at 15:24
  • @Marko I also thought maybe it was a validation issue (as this uses a database I didn't design myself). I added validation and Model.IsValid around the try catch but didn't end up catching anything there either. – sebe Aug 28 '15 at 15:51
  • I am not sure this is a session issue but whatever it is there should be an error so I suggest to spend a little time to uncover this error. Have a look [here](http://blogs.msdn.com/b/webdev/archive/2012/11/16/capturing-unhandled-exceptions-in-asp-net-web-api-s-with-elmah.aspx). This article shows how to do it for web API but will also work for MVC. – Ares Aug 28 '15 at 15:46

1 Answers1

0

It sounds like a session issue to me as well. Perhaps you could try setting the session timeout to a very small value (e.g. 1 minute) and seeing if the behavior replicates itself after that time? Alternatively, you could try restarting IIS while on the page - that should effectively flush the session. If that does turn out to be the problem, you can always increase the session state timeout.

In case you weren't aware, the session state timeout value can be modified within web.config:

<sessionState timeout="30" />

Or within IIS Manager under Session State for the specific site.

Matthew
  • 777
  • 1
  • 9
  • 23
  • Just tried setting this to timeout="1" and wasn't able to reproduce the problem as described. I'm currently letting it sit while I do other work for the next 30 minutes to see if it'll change it's mind about reproducing the error for me. :) – sebe Aug 28 '15 at 20:18