Maybe I was skimming too quickly, but I had to do a serious double take and slow down on the section regarding the page directive,
"Update the Edit, Details, and Delete Razor Pages to use the "{id:int}" route template. Change the page directive for each of these pages from @page to @page "{id:int}"."
It might be helpful to mention that this is at the top/first part of the code.
Nevertheless, thanks for an amazing tutorial. This stuff just finally might make sense. MANY THANKS
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@louvipi thanks for your suggestion.
The section about making the ID optional using @page "{id:int?}" did not work for me. Are you sure this is correct?
Yes, it's correct.
The section about making the ID optional using @page "{id:int?}" did not work for me. Are you sure this is correct?
Agreed, because the behavior is the same (page not found) whether the ID is set to optional or not. So it's not entirely clear what the difference is. Is there an example or scenario where we would want to leave the ID optional?
@page "{id:int}"
https://localhost:44343/Movies/Details/
results in 404 error and BP in Pages\Movies\Details.cshtml.cs is never hit.
@page "{id:int?}"
set break point in Pages\Movies\Details.cshtml.cs
and BP is hit.
@page "{id:int}"
https://localhost:44343/Movies/Details/
results in 404 error and BP in Pages\Movies\Details.cshtml.cs is never hit.@page "{id:int?}"
set break point in Pages\Movies\Details.cshtml.cs
and BP is hit.
A perfect clarification, thank you!
@helpimajosh thanks.
I'll add this next time I'm updating the doc.
Most helpful comment
The section about making the ID optional using @page "{id:int?}" did not work for me. Are you sure this is correct?