N2 MVC controller action caching?

Topics: Developer Forum
Mar 7, 2009 at 4:39 PM

Hi all,

I've got a really odd problem when using N2 with MVC. It seems to be related to the N2 side of things, as it doesn't happen within a purely MVC only app I wrote to test. Basically, when making calls to controller actions from within a page, the controller action parameters act as if they're being cached if they get called more than once.

As an example, I have articles that contain comments. If a user wishes to add a comment, a call is made to the AddComment action method of the CommentController. The first time a user adds a comment, this works fine. However, every subsequent call to that same routing path, with a different set of parameters (ie - someone puts another, different comment), the parameters that end up being passed to the AddComment action are exactly the same as the very first time it was called.

The only way to stop this is to basically kill the app and restart it. Then, when someone adds a comment, as before, it'll work fine, but all subsequent comments end up being the same. I'm totally out of ideas as to why this might be happened.

Does anyone have any ideas as to why this might be?

Many thanks.

Coordinator
Mar 8, 2009 at 1:42 AM
I'll see if I can figure this out. You could help out by reproducing the issue on the MVC example site.
Mar 8, 2009 at 7:10 AM
Hi Libardo,

Thanks for the help. One of my colleagues had a thought last night which has actually resolved the issue now. It's a stupid mistake on our part. We're using Castle to handle dependancies, and we needed to make the controllers transient. Simple as that.

Sorry for the mistake. Everything's working perfectly now.

Paul