Should MVC display pagination information along a path or quest?

On my way:

Format: http://mydomain.com/ {category} / {subcategory} / {pageNumber} / {pageSize}

Example: http://mydomain.com/books/thriller/3/25

In the request:

Format: http://mydomain.com/ {category} / {subcategory}? PageNumber = {PageNumber} & PAGESIZE = {PAGESIZE}

Example: http://mydomain.com/books/thriller?pageNumber=3&pageSize=25

I like to have everything in its path, but my problem is that although it is obvious (or at least somewhat obvious) that the β€œbooks” and β€œthriller” in the first example, β€œ3” and β€œ25”, seem pretty arbitrary.

Is there a canonical method for determining what happens where the MVC is located, or is it really only up to dev?

+6
query-string model-view-controller path pagination
source share
6 answers

I prefer variables like pagenumbers over query variables. I think there is a difference in descriptiveness between

http://mydomain.com/books/thriller?pagesize=50&page=4 

and

 http://mydomain.com/books/thriller/50/4 

The point (for me) of having a clean URL for them is more descriptive and readable, and I believe that this is the first example.

One interesting point made by JohnRudolfLewis :

One rule of thumb that I follow is that if an argument is required, consider using a path; if the argument is optional, always use query arguments.

+17
source share

One rule that I follow is that if an argument is necessary, consider using a path; if the argument is optional, always use query arguments.

In general, I adhere to what makes the URL more understandable.

This site puts it in the query string: https://stackoverflow.com/questions?page=2&pagesize=30

+6
source share

Well, that is obviously up to you. But you are developing a RESTful interface that should be human readable. In this regard, the request is much better. Otherwise, you are looking at two numbers that can really be anything. And who will remember the order?

+3
source share

Is there a canonical method for determining what happens where the MVC is located, or is it really only up to dev?

This is for you.

MVC refers to the organization / flow of your code on the server side and shares the view at the business level, not the query parameters.

+1
source share

You can also consider the following

Format

 http://mydomain.com/{category}/{subcategory}/page/{pageNumber}/results/{pageSize} 

Example

 http://mydomain.com/books/thriller/page/3/results/25 
0
source share

It pretty much depends on the developer. I would say put the page URL in the URL.

-one
source share

All Articles