We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,318 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Stop page refresh

I use Mvc 4 with razor. I have a View that in back end creates a database entry in Action method. Problem is when i refresh the page (Press F5) the back end method calls again and create duplicate of the database entry. How to stop this?

 public ActionResult SummaryPage()
 { 
    bool createdatabaseEntry = NotifyCreateDatabaseEntry();

   if (createdatabaseEntry)
    {
        // pop up success massage
    }
    else
    {
        // pop up error massage
    }

     return View();
 }

 public bool createdatabaseEntry : this method connect to the db

Please help
thank you in advance

2
Contributors
1
Reply
1 Week
Discussion Span
2 Months Ago
Last Updated
13
Views
jrosh
Junior Poster
186 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

I have a View that in back end creates a database entry in Action method. Problem is when i refresh the page (Press F5) the back end method calls again and create duplicate of the database entry. How to stop this?

Read this ( it will explain how to avoid duplicate ):

http://forums.asp.net/t/1848294.aspx/1?Best+practice+to+Avoid+Duplicate+record+insertion+on+page+refresh

Also read this

http://aspalliance.com/687_Preventing_Duplicate_Record_Insertion_on_Page_Refresh

and this:

http://www.dotnetvishal.com/2012/10/avoid-duplicate-record-insertion-on.html

Both links have examples which you can used to prevent duplicate records

LastMitch
Industrious Poster
4,374 posts since Mar 2012
Reputation Points: 149
Solved Threads: 350
Skill Endorsements: 47

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page generated in 0.0579 seconds using 2.66MB