asp.net-mvcrhino-commons

Rhino Commons UnitOfWork and ASP.NET MVC Controller seem to be caching parameters


I am using Rhino Commons UnitOfWork in my controller methods. The first request retrieves the data and displays it correctly. My problem is when I change the parameters in the URL they are not passed to the controller. The values from the previous request are used.

My controller method is listed below:

    public ActionResult List(int year, int? month, int? day)
    {
        IList<Meeting> meetings;

        using (UnitOfWork.Start()) {
            meetings = _meetingRepository.GetByDate(year, month, day);
        }

        return View("List", meetings);
    }

The Global.asax.cs inherits from UnitOfWorkApplication

The initial request to ~/meetings/2009 returns all meetings for the year 2009. The next request to ~/meetings/2007 returns all meetings for the year 2009.

This is occuring while debugging in Visual Studio. I have not had a chance to move to IIS to see if the same problem occurs.

Am I doing something wrong in my use of UnitOfWork, or could it be a problem somewhere else?


Solution

  • My guess is that the whole UnitOfWork thing is a red herring... The controller being passed values from previous requests sounds like the same instance of the controller is being re-used for multiple requests. The ASP.NET MVC framework works under the assumption that each request is handled by a fresh instance of the controller.

    So, with that in mind, how are you constructing your controllers? For example if you're using a IoC framework like Spring.NET make sure your controllers are not singletons.