markjprice / apps-services-net8

Repository for the Packt Publishing book titled "Apps and Services with .NET 8" by Mark J. Price
96 stars 47 forks source link

Shipper Action Incorrect #18

Open DocVD opened 2 weeks ago

DocVD commented 2 weeks ago

On page 649, step-16, another anchor tag is used to pass dictionary to current page: <a asp-controller="Home" asp-action="Shipper" asp-all-route-data="await GetShipperData()" class="btn btn-outline-primary">Shipper

However, this produces the error: An unhandled exception occurred while processing the request. InvalidOperationException: The view 'Shipper' was not found. The following locations were searched: /Views/Home/Shipper.en-US.cshtml /Views/Home/Shipper.en.cshtml /Views/Home/Shipper.cshtml ... So I modified the asp-action="asp-action="Index" instead and I get no issues. Is that what is expected?

markjprice commented 2 weeks ago

In Step 13, you should have created a Razor view named Shipper.cshtml in the Views/Home folder: image As you can see from your error message, ASP.NET Core cannot find that file. Check that you have that file and that it is NOT a Razor Page (it must NOT have a @page directive at the top.)

markjprice commented 2 weeks ago

I have created an improvement item for this here: https://github.com/markjprice/apps-services-net8/blob/main/docs/errata/improvements.md#page-648---exploring-the-anchor-tag-helper

image