How do I prevent multiple form submission in .NET MVC without using Javascript?

后端 未结 13 2157
情深已故
情深已故 2020-11-28 02:36

I want to prevent users submitting forms multiple times in .NET MVC. I\'ve tried several methods using Javascript but have had difficulties getting it to work in all browser

13条回答
  •  被撕碎了的回忆
    2020-11-28 03:09

    Use the Post/Redirect/Get design pattern.

    PS: It looks to me that the answer by Jim Yarbro could have a fundamental flaw in that the __RequestVerificationToken is stored in the HttpContext.Current.Session["LastProcessedToken"], this value will be replaced when a second form is submitted (from say another browser window), at this point it is possible to re-submit the first form and it won’t be recognized as a duplicate submission? For the proposed model to work wouldn’t a history of __RequestVerificationToken be required(?), this wouldn’t be feasible.

提交回复
热议问题