Add static segment to route to make pagination more friendly asp.net core

Viewed 651

In my website I made my urls in general more friendly by using slugs. I would like to make the url information related to paging more friendly too by changing

 www.example.com/controller/action/1  // 1 represents the page

to

 www.example.com/controller/action/page-1 

I don't care if it isn't possible but it would be desirable.

I've tried to decorate my action with

[Route("action/page-{pagina?}")]
public IActionResult Action(int page= 1)

when navigating a get this.

the optional parameter 'page' is preceded by an invalid segment 'page-'

2 Answers
Related