Question

I'm using PRG Pattern for HTTP Post in MVC. While I read about this I got some positive feedback on this method. And I felt this is the best approach.

Here is the reference: Post-Redirect-Get article on Andre Loker blog.

But when I use this, there is a disadvantage I've came across:

I've pagination in my page. When I am in 5th page - if I post any data, then it'll be redirected by PRG. So It goes to 1st page. I want to stay on the same 5th page.

So my question is: how to preserve opened page after posting a request?

Was it helpful?

Solution

Instead of

return RedirectToAction("Action","Controller")

Use like the following

return Redirect(Url.Action("Action","Controller") + Request.Url.Query);

OTHER TIPS

To stay on the same page, you have to send along the page number when you post the data, so that the server code can use that to redirect to an URL that shows that page.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top