Should I Use Cookies to Store IDs for Deletion in ASP.NET Core?
Asked by
dial..tone..again
Hey everyone, I'm wondering about the best way to handle IDs for deletion in my ASP.NET Core app. When a user clicks the delete button, it takes them to another page where they can see detailed info about the row, like an employee's data, with the ID showing up in the URL (e.g., id=12).
Would it be better to use something like `Request.Query["id"]` to get that ID and pass it directly to a stored procedure for deletion? Or would it be smarter to create a cookie to hold that ID and retrieve it from there? I know you can't store a value in `OnGet` and use it in `OnPost` since they are different states, so I'm curious how you all handle this situation!
Answers
Another option is to include a hidden input field within a form that wraps your delete button, which holds the ID. Since you need to display the data to your users anyway, you can directly use that ID without relying on cookies or query strings!
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions