• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 557
  • Last Modified:

How to implement Auditing in ASP.NET Application.

User performs some operation say for example Place an order, Delete an order and so on.
 
How to implement Auditing?

If you provide sample application that could be grateful. Thanks.
0
Easwaran Paramasivam
Asked:
Easwaran Paramasivam
  • 4
  • 4
3 Solutions
 
Padre_CorleoneCommented:
I don't have sample but I could provide information of what I would do.  You can create triggers in the database which can write to an audit table every time there's inserts, uPdates, deletions and you could store the action and user I'd I database as a log.
0
 
Easwaran ParamasivamAuthor Commented:
Thanks. How would you access logged in username in trigger.?
0
 
Padre_CorleoneCommented:
I recommend passing the user I'd when changing data back to the database. By the userid you can get the username incase you need to have a page that displays all the relevant information with actions.
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
Easwaran ParamasivamAuthor Commented:
But for triggers we could not pass parameters. Isn't it? How to tackle this situation?
0
 
Padre_CorleoneCommented:
Example on stored procedure update pass the parameter into stored procedure and on trigger retrieve it.  There are plenty of examples on the Internet.  

www.rahulsingla.com/blog/2010/11/sql-server-passing-parameters-to-triggers
0
 
Easwaran ParamasivamAuthor Commented:
I've seen the above article. That is nice.

They asked to store the username in a Session variable and read latter in Trigger. What about multiple users logged in the application at the same time? How to handle that case?
0
 
Padre_CorleoneCommented:
Each use will have a unique session id and hopefully different user account.  So each request sent to the database like submitting an order will create a new process identification for that user request so can't have over lapping logged users in the application.
0
 
Easwaran ParamasivamAuthor Commented:
Thanks.
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now