Hello,
I have encountered what I expect is a common issue in web development. I have an ASP.NET MVC 2.0 ecommerce site. I pass the cost of an item to the product page view via a viewmodel - this cost may vary based on user type, user history, quantity purchased, etc.
I want to guarantee that when the user submits the form to purchase said product, the cost that I originally sent is the same i.e. the cost property in the viewmodel has not changed. For a normal user this is not a problem, but for someone malicious it is relatively simple to change the value en route so that my product costs, for example $1 instead of $999.
Obviously, I could go back to the DB and recalculate the cost once the form has been submitted - but this seems like an expensive operation and I'm wondering how this is normally done. The obvious solution in my mind is getting the hashcode (or just encrypt the value) of the field and add it as a hidden input to the form and ensure that the hashcode (or encrypted value) of the cost field is the same.
Can anyone tell me how this is regularly done and/or if there are issues with my proposed solution?
Thanks in advance,
JP