asp.net mvc 控制器工厂

发布于 2024-12-17 05:49:13 字数 627 浏览 0 评论 0原文

我想实现这样的目标:

  1. 我想审核所有参与向视图文件提供 http 请求的控制器。

  2. 我想审核该控制器上的每个方法并将此信息写入平面文件(滚动记录器??)。

  3. 审核日志应包含:经过身份验证的用户信息、调用的方法方法参数时间戳

我意识到这需要实现我自己的控制器工厂来执行类似的操作:

    //policy injection call that is set up to log all the methods, called on the 
   //controller.
   var myController = ControllerCustomerFactory<FlatRollingLogger>.Create();

下一步我应该做什么,我应该将自定义创建的控制器注入其他地方还是工厂将跟踪需要实例化的控制器?

我在想 Microsoft Ent Lib 策略注入,因为它已经在我们公司用于其他审计目的了?

还有其他更好的想法来处理这个问题吗?

谢谢

I would like to achieve something to this extent:

  1. I want to audit all of my controllers participating in serving http requests to the view files.

  2. I would like to audit each and every method on that controller and write this information to the flat file (rolling logger??).

  3. The audit log should contain: authenticated user info, method called, method parameters, time stamp.

I realize that this would require implementing my own controller factory to do something like this:

    //policy injection call that is set up to log all the methods, called on the 
   //controller.
   var myController = ControllerCustomerFactory<FlatRollingLogger>.Create();

what should I do next, should I inject the custom created controller somewhere else or the factory will keep track on which controller needs to be instantiated?

I was thinking Microsoft Ent Lib Policy Injection as it has been done for other auditing purposes in our company?

Any other better ideas to handle this?

merci

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷月断魂刀 2024-12-24 05:49:13

不,您不需要自己的工厂控制器,只需创建一个全局操作过滤器即可。 MVC 具有很强的可扩展性。

http:// /weblogs.asp.net/gunnarpeipman/archive/2010/08/15/asp-net-mvc-3-global-action-filters.aspx

No, you don't need your own factory controller, just create a global action filter. MVC is very extensible.

http://weblogs.asp.net/gunnarpeipman/archive/2010/08/15/asp-net-mvc-3-global-action-filters.aspx

悸初 2024-12-24 05:49:13

您可能需要考虑使用 PostSharp 等框架的面向方面的方法。您可以使用日志框架(例如 log4net )来执行实际日志记录。

You might want to consider an aspect oriented approach using a framework such as PostSharp. You can use a logging framework such as log4net to perform the actual logging.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文