开发者

Tracking user changes in ASP.NET MVC

I have a requirement to track what authenticated users change with regards to the data when logged in. I don't need to track what pages they look at although that could be very useful in future.

I have thought about saving the User Guid but that seems very clunky. I do need to do simple stuff like old value and new value. I am using the开发者_JAVA技巧 Entity Framework is there support for that in there with stored procedures in SQL Server?

Are there other methods/best practises?


This isn't really an ASP.NET MVC question. You can implement auditing in your EF layer. Here's a quick sample I just found.

I've found that the trick with auditing is understanding why you need to have the support. Often times a user will say they want auditing, but really they just want to know a last edit date/user. You should know if they need undo capability, security audits, etc. Is this for regulatory compliance or for a DBA to fix user errors? Often times it's simpler to dlete and reenter data than to manually edit a DB. Also, how would rolling back data affect other reporting concerns? If you've changed data and rerun a report it will not match the original. If this is an issue you need to store the original results or have an event sourcing model. Not fun.

The second difficult thing about auditing is figuring out how to display the data. Sometimes SQL queries are acceptable, other times users want a full history in the UI. My suggestion is to review the business needs of your case and research appropriate implementations.

Also, if you need to audit relationship changes in a database there is no simple solution. Good luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜