Select action for refresh ASP.NET MVC

132 views Asked by At

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

0

There are 0 answers