开发者

Can I use another pattern or method than PRG in this case?

I'm not sure if the PRG pattern is the right choice in my case. Before I introduce my case, PRG stands for Post/Redirect/Get and you can read up on it here: Wiki-article

I've got a search page, the search is done with a POST request (an开发者_开发知识库d there's a lot of parameters). You typically search for orders, and you can search on address, dates, persons and so on. Lets say you do a search and then open an order. Now, if you go back, your client asks you with an annoying pop-up: "Do you want to resend the post request with its parameters?" (or something like that).

That pop-up is annoying, and I dont think my customer would like to have it :)

I was thinking, maybe it would be good to store the post parameters in the session, provide a link (so you have to use that link, and cannot click "back" in your client) which makes a new post request with those parameters stored in the session, and there will be no annoying pop-up...

Then I googled around and found the PRG pattern, which seems complicated and requires some extra coding. My concern to the whole idea, why not just make the whole search use GET instead of POST.

So this issue/question of mine is asking:

  • Should I use POST or GET for my search
  • If I use POST, is my idea or the PRG pattern better?

Thanks!


If you want the resulting URI to be shared, and/or as concise as possible - use PRG. If you care more about performance, easily read code and an out-of-the-box solution - use GET.

Google uses GET for example and ends up with a really ugly URI - but it works and it's fast.

If you use a SESSION you take up unnecessary space to save it and you can not link to the result since the URI does no longer represent the stage of the page which is a bad thing. I'd use PRG instead.


Should I use POST or GET for my search

GET, definitely.

PRG pattern is just inapplicable here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜