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

Member Avatar for LastMitch

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.