After setting up pagination for my web app, I decided to change the url so that it looks nicer. Everything worked perfectly until I decided to add a route which gives me the following error after I change page
"InvalidOperationException: The view 'Books' was not found. The following locations were searched: /Views/Shared/Books.cshtml"
And the routing
routes.MapRoute
(
name: "pagination",
template: "Books/Page/{page}",
defaults: new {Controller = "Core", action = "Books"}
);
There doesn't seem to be any typo and I've checked thrice that the controllers and views are in the correct path and have the correct methods. What may be the problem here? Its not searching in the right folder for the view
Could you make
page
optional and try again? If page is null inside Books action method, then you could throw a custom error inside the method.Or use attribute routing.