N2 MVC 控制器操作缓存?
在 MVC 中使用 N2 时,我遇到了一个非常奇怪的问题。 它似乎与事物的 N2 方面有关,因为它不会发生在我编写测试的纯 MVC 应用程序中。 基本上,当从页面内调用控制器操作时,如果控制器操作参数被多次调用,则它们就像被缓存一样。
例如,我有包含评论的文章。 如果用户希望添加评论,则调用 CommentController 的 AddComment 操作方法。 用户第一次添加评论时,效果很好。 然而,每次后续调用同一路由路径时,都会使用一组不同的参数(即,有人添加另一个不同的注释),最终传递给 AddComment 操作的参数与第一次调用时完全相同叫。
阻止这种情况的唯一方法是基本上终止该应用程序并重新启动它。 然后,当有人添加评论时,就像以前一样,它会正常工作,但所有后续评论最终都是相同的。 我完全不知道为什么会发生这种情况。
有谁知道为什么会这样?
非常感谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
终于找到答案了。 我们一直使用 Castle 来处理依赖关系,并且没有将任何控制器设置为瞬态的。 哎哟!
Found the answer finally. We'd been using Castle to handle dependencies, and hadn't set any of the controllers to be transient. Doh!