Should I Use Cookies to Store IDs for Deletion in ASP.NET Core?

0
11
Asked By CuriousCoder94 On

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!

1 Answer

Answered By DevNinja33 On

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!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.