Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Document the two host-detection idioms and guard _ViewStart on a null area
KrzysztofPajak38db1e8337d2
diff --git a/src/Web/Grand.Web.AdminShared/Views/AdminShared/_ViewImports.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/_ViewImports.cshtmlindex ffa2936d5..99532cee9 100644--- a/src/Web/Grand.Web.AdminShared/Views/AdminShared/_ViewImports.cshtml+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/_ViewImports.cshtml@@ -19,3 +19,10 @@@inject LocService Loc@inject IEnumTranslationService EnumTranslationService@inject IAdminDataScope<Product> Scope++@* Two host-detection idioms in these shared views; do not invent a third.+ Scope.ResourceKeyPrefix — "Admin" or "Vendor". Use for anything the same in Admin and Store but+ different in Vendor: resource keys, and capability differences Vendor doesn't have.+ ViewContext.RouteData.Values["area"] — "Admin", "Store" or "Vendor". Use ONLY when Admin must be+ told apart from Store; both report ResourceKeyPrefix == "Admin", so it cannot distinguish them.+ The same "area" route value drives RoutedProductDataScope, so the two cannot drift apart. *@diff --git a/src/Web/Grand.Web.AdminShared/Views/AdminShared/_ViewStart.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/_ViewStart.cshtmlindex 7447c721b..cbfdf5cb1 100644--- a/src/Web/Grand.Web.AdminShared/Views/AdminShared/_ViewStart.cshtml+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/_ViewStart.cshtml@@ -1,5 +1,8 @@@using Microsoft.AspNetCore.Routing@{var area = Context.GetRouteValue("area")?.ToString();- Layout = $"~/Areas/{area}/Views/Shared/_{area}Layout.cshtml";+ if (!string.IsNullOrEmpty(area))+ {+ Layout = $"~/Areas/{area}/Views/Shared/_{area}Layout.cshtml";+ }}