Update a record in ASP .Net MVC

StrugglingCoder

Today in the interview I faced a question tat I had no clue about. Being a newbie into ASP .Net MVC I had no other way but to ask the experts about it.

"In your MVC Application ,data are being stored into a RDBMS System. In a .cshtml page ,there is a button to update the existing records into DB.

Now suppose two users from different parts of the Globe are at the same time are trying to update a common record. But by the the time the second user hits the submit button, you already submitted the update. In that case the second user , when would be pressing the submit won't be able to submit. Instead the page would reloaded for the second user with the updated info, discarding the changes.And then only he would be able to go on with the update"

How could you achieve that in ASP .Net MVC?

I though thought it might be something from the DB Side coding also , but I have no clue how to achieve the same.

Mike Brind

You need to implement a strategy for managing concurrency. How you do this depends largely on the business rules of the application and the type of conflict that arises when two or more people attempt to change the same record.

Most often, you will add a column called RowVersion which will be a timestamp type. Whenever you display records to be updated, you also select the current RowVersion value and usually store it in a hidden field. The update operation will include the RowVersion field, which gets a new value, but before you commit an update operation, you compare the RowVersion value you have with the current one in the database. If they are different, someone else has updated the row during the time that it took you to get the record to be updated and then tried to change it. You determine how to proceed based on the application's business rules.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Update a record in ASP .Net MVC

From Dev

ASP.NET MVC Core update record stored procedure returning nothing

From Dev

ASP.NET MVC record status

From Dev

Unable to update cookies in asp.net mvc

From Dev

How to Update Model in ASP NET MVC 6?

From Dev

displaying last record in the database asp.net mvc

From Dev

ASP.NET MVC Telerkik AutoComplete Not displaying record

From Dev

Duplicate record in db with Json Create Action Asp.Net MVC

From Dev

insert Multiple new record in databse asp.net mvc

From Dev

ASP.NET and SQL Server : update last record with dynamic values

From Dev

ASP.Net MVC Infragistics igGrid - readonly attributes for updating a record, non-readonly attributes for adding a record

From Dev

Separate ViewModel for Read, Create, and Update actions in ASP.NET MVC

From Dev

How to update asp net webforms or mvc application without losing session?

From Dev

How to update image with JavaScript and ASP.NET MVC?

From Dev

Asp.Net MVC Partial View Update with Ajax

From Dev

Asp.net core mvc update after approval

From Dev

asp.net mvc web api partial update with OData Patch

From Dev

Update multiple records at once in asp.net mvc

From Dev

Full Calendar ASP.NET MVC update database eventDragStop

From Dev

ASP.Net MVC Update ViewModel on DropDown Selection changed

From Dev

ASP.NET MVC bundle won't update if loaded dynamically

From Dev

Update my ASP.NET MVC4 project templates?

From Dev

ASP.NET MVC 4 - Update Model from View

From Dev

asp.net mvc web api partial update with OData Patch

From Dev

Best ASP.NET MVC Async Update Patterns

From Dev

How to update table in ASP.NET MVC 5 Razor Database

From Dev

javascript or ajax to update database with asp.net mvc?

From Dev

Separate ViewModel for Read, Create, and Update actions in ASP.NET MVC

From Dev

I need to apply update and delete in asp.net MVC 4

Related Related

  1. 1

    Update a record in ASP .Net MVC

  2. 2

    ASP.NET MVC Core update record stored procedure returning nothing

  3. 3

    ASP.NET MVC record status

  4. 4

    Unable to update cookies in asp.net mvc

  5. 5

    How to Update Model in ASP NET MVC 6?

  6. 6

    displaying last record in the database asp.net mvc

  7. 7

    ASP.NET MVC Telerkik AutoComplete Not displaying record

  8. 8

    Duplicate record in db with Json Create Action Asp.Net MVC

  9. 9

    insert Multiple new record in databse asp.net mvc

  10. 10

    ASP.NET and SQL Server : update last record with dynamic values

  11. 11

    ASP.Net MVC Infragistics igGrid - readonly attributes for updating a record, non-readonly attributes for adding a record

  12. 12

    Separate ViewModel for Read, Create, and Update actions in ASP.NET MVC

  13. 13

    How to update asp net webforms or mvc application without losing session?

  14. 14

    How to update image with JavaScript and ASP.NET MVC?

  15. 15

    Asp.Net MVC Partial View Update with Ajax

  16. 16

    Asp.net core mvc update after approval

  17. 17

    asp.net mvc web api partial update with OData Patch

  18. 18

    Update multiple records at once in asp.net mvc

  19. 19

    Full Calendar ASP.NET MVC update database eventDragStop

  20. 20

    ASP.Net MVC Update ViewModel on DropDown Selection changed

  21. 21

    ASP.NET MVC bundle won't update if loaded dynamically

  22. 22

    Update my ASP.NET MVC4 project templates?

  23. 23

    ASP.NET MVC 4 - Update Model from View

  24. 24

    asp.net mvc web api partial update with OData Patch

  25. 25

    Best ASP.NET MVC Async Update Patterns

  26. 26

    How to update table in ASP.NET MVC 5 Razor Database

  27. 27

    javascript or ajax to update database with asp.net mvc?

  28. 28

    Separate ViewModel for Read, Create, and Update actions in ASP.NET MVC

  29. 29

    I need to apply update and delete in asp.net MVC 4

HotTag

Archive