0

Can you determine which action will be used when you refresh the page?

I am using PRG pattern in my ASP.NET MVC web application. I have 4 dropdowns in my view for selecting item x and item y

2 for groups x and y and 2 for items x and y within group x and y. First you select groups then you select items

But some items don't belong to any group, so you can choose them as groups. F.e. you choose "resolution" as group x which is an item without a group, so I set item x as "resolution" in the controller. When someone deselects "resolution" as item x in dropdown I still want to set it in controller as item x. For this I need PRG pattern, because it woulnd't work without it.(or clearing modelState)

I have 2 action methods.

  • [HttpGet] Index - set default settings and initializes data if not redirected from Post method and returns View
  • [HttpPost] Index - loads data according to settings and redirects to [HttpGet] Index

And after using refresh/F5 the action method that starts executing is [HttpGet] Index, but I would like to the Post method to start executing so I can keep user's settings in model

  • But I have 4 dropdowns, 2 for groups and 2 for items in those groups, but some items have no group so they can be set with groups. So when someone chooses such item as group I set it also as item in the Post action method. –  Dec 16 '17 at 16:13
  • Unclear to me, add some description to the question – Divyang Desai Dec 16 '17 at 16:21
  • I edited the question, hope it's clear now –  Dec 16 '17 at 16:30

0 Answers0