开发者

ASP.net web application data integrity issue

开发者 https://www.devze.com 2023-03-03 18:23 出处:网络
Let say... If we ASP.net bank开发者_JS百科ing application. When user press a button then it will debit $100 from his account.

Let say...

If we ASP.net bank开发者_JS百科ing application. When user press a button then it will debit $100 from his account.

Issue: What happened if user two or three times click on this button without waiting for first inform or it press F5/refresh page.

How we can prevent or get data integrity.


If you are using any ASP.Net ajax, Postback Ritalin will help prevent multiple postbacks.


The easiest way to prevent users from submitting the same form multiple times is to simply disable the button, posting your form back. That way they can't accidentaly re-submit it before the page gets processed.

Also, passing through a random piece of string alongside with the other form variables can help you as well. In that case you could compare the string (alongside with other information) to see if previously you've processed a request that had matching details.


Am guessing/hoping this is an exam question of some kind? Anyways, here a couple of pointers;

look into transactions (for the sum to add up) and perhaps optimistic concurrency (to avoid changing what have been updated by others)

good luck!

BR

Daniel

0

精彩评论

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

关注公众号