Skip to content

fix(admin): resolve partial-view name collision in Order AddressEdit - #798

Merged
KrzysztofPajak merged 1 commit into
developfrom
fix/order-address-partial-view-collision
Aug 26, 2026
Merged

fix(admin): resolve partial-view name collision in Order AddressEdit#798
KrzysztofPajak merged 1 commit into
developfrom
fix/order-address-partial-view-collision

Conversation

@KrzysztofPajak

Copy link
Copy Markdown
Member

Type: bugfix

Issue

Editing a billing or shipping address on an order in the Admin panel (Admin/Order/AddressEdit?addressId=...&orderId=...&BillingAddress=True) threw:

InvalidOperationException: The model item passed into the ViewDataDictionary is of type 'Grand.Web.AdminShared.Models.Orders.OrderAddressModel', but this ViewDataDictionary instance requires a model item of type 'Grand.Web.Models.Common.AddressModel'.

Root cause: src/Web/Grand.Web.AdminShared/Views/AdminShared/Order/AddressEdit.cshtml rendered a partial named Partials/CreateOrUpdateAddress. That relative name collided with the storefront's own src/Web/Grand.Web/Views/Shared/Partials/CreateOrUpdateAddress.cshtml (@model AddressModel). In the combined Grand.Web host, ASP.NET Core's default area view-location fallback /Views/Shared/{0}.cshtml is checked before the repo's custom ViewLocationExpander fallback onto /Views/AdminShared/{1}/{0}.cshtml, so the storefront's AddressModel-based partial was resolved instead of the intended OrderAddressModel-based AdminShared partial, causing the model-type mismatch.

Reproduce: open any order in Admin, click edit on the billing or shipping address.

Solution

Renamed the colliding AdminShared partial from Partials/CreateOrUpdateAddress to Partials/OrderCreateOrUpdateAddress (no other file in the repo uses that exact relative partial path), and updated the single reference to it in AddressEdit.cshtml. This is a pure rename with no behavior change to the partial's content, so Admin, Vendor, and Store hosts (which all share this AdminShared controller/view) are fixed identically.

Breaking changes

None. This is an internal view-file rename; no public contract, model, or route changed.

Testing

  1. Open Admin panel, go to an existing order.
  2. Click "Edit" on the billing address (or shipping address).
  3. Confirm the AddressEdit page renders without an InvalidOperationException, showing the address edit form correctly populated.
  4. Change a field and save; confirm the address updates and you are redirected back to the AddressEdit page for the same address without error.
  5. Repeat steps 2-4 for the shipping address.

Admin/Order/AddressEdit threw InvalidOperationException: the model item
passed into the ViewDataDictionary is of type OrderAddressModel, but the
ViewDataDictionary instance requires AddressModel.

Root cause: the shared partial "Partials/CreateOrUpdateAddress" used by
Grand.Web.AdminShared's Order/AddressEdit.cshtml has the same relative
name as the storefront's own Views/Shared/Partials/CreateOrUpdateAddress.cshtml
(@model AddressModel) in Grand.Web. In the combined host, ASP.NET Core's
default area view location fallback "/Views/Shared/{0}.cshtml" is checked
before the project's own custom AdminShared fallback location, so the
storefront's partial (bound to AddressModel) was resolved instead of the
intended AdminShared Order partial (bound to OrderAddressModel), causing
the model type mismatch.

Fix: rename the AdminShared Order partial to
Partials/OrderCreateOrUpdateAddress, which no longer collides with any
storefront view name, and update the one reference to it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QArzgnTu2jhTmm4LiMjuNF
Copilot AI lite review requested due to automatic review settings August 26, 2026 19:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@KrzysztofPajak
KrzysztofPajak merged commit 271aa57 into develop Aug 26, 2026
5 checks passed
@KrzysztofPajak
KrzysztofPajak deleted the fix/order-address-partial-view-collision branch August 26, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants