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.
Standard: Razor and Frontend
Rules for .cshtml, storefront JavaScript, and theme assets. Complementary to .ai/skills/template-creation.md (procedure) and .ai/knowledge/template-types.md (where each template type lives).
Razor
- Strongly typed models:
@modelat the top, matching the type the action returns. - Localization through the injected
LocService:@Loc["Resource.Key"]. Never hardcode user-facing text. - Tag helpers come from
_ViewImports.cshtml. Every view folder that needs them must have one — plugins and themes each need their own. - Storefront
_ViewImports.cshtmlremoves the defaultInputTagHelperto avoid duplicated checkboxes. Copy that@removeTagHelperline when creating a theme's_ViewImports.cshtml. - URLs through
Url.RouteUrl(...)with named routes where nearby views do; do not hand-build paths. - Widget zones stay where they are:
@await Component.InvokeAsync("Widget", new { widgetZone = "..." }). Removing a zone is a breaking change for every installed widget plugin. - Forms use antiforgery. AJAX mutations call
addAntiForgeryToken(data)where nearby views do. Html.Rawonly for content that is trusted or already sanitized.
Preserve on every product/catalog view you touch
data-cart-action, product IDs, quick-view URLs, wishlist and compare attributes, and image alt / title / loading / priority attributes. These are contracts with the storefront JavaScript, not decoration.
Vue in Razor
- Database-sourced HTML rendered through
Html.Rawinside a Vue-controlled subtree is compiled as a template. Wrap it inv-prewhen it may contain{{ }}. - Keep view-model JSON out of inline
<script>blocks; use the[data-grand-vm]island convention. - Do not introduce a second frontend framework for one template.
Assets
- Storefront source assets live in the Vite app; generated bundles are committed alongside the source. Follow
.ai/skills/frontend-bundle-workflow.mdfor whennpm run buildis required and which output files must be committed. - Theme-owned CSS/JS lives under the theme plugin's
Content/folder and is copied withCopyToOutputDirectory=PreserveNewest. - Do not reference external CDNs from storefront views.
Admin views
- The panels are on Bootstrap 5.3 with bootstrap-icons, both built by
adminapp. Write Bootstrap 5 names:ms-*/me-*notml-*/mr-*,text-start/text-end,mb-3notform-group,form-checknotcustom-control,form-selecton a<select>(aselect.form-controlloses its arrow in Bootstrap 5),visually-hiddennotsr-only,text-bg-*next tobadge,btn-closenotclose,data-bs-togglenotdata-toggle, and no input group wrapper element. Icons are<i class="bi bi-name">; the list is at https://icons.getbootstrap.com/, andbi-fwgives the fixed-width box Font Awesome'sfa-fwdid. - Never write a
k-*class. Kendo is gone, and nothing maps those names any more. - The panel chrome lives in
adminapp/src/styles/_custom.scss, not inwwwroot.x_panel/x_title/x_contentare the three structural names an admin screen is built from and are driven by Bootstrap's--bs-card-*properties. - Use the admin tag helpers for labels, inputs, validation, cards, tabs, and grids rather than raw Bootstrap markup.
- New and reworked admin screens, tabs and popups use the component layer -
<admin-page>,<admin-card>,<admin-field>,<admin-filters>,<admin-bulkbar>,<admin-action-menu>,<admin-popup>- and its rules: onebtn-primaryper screen, destructive actions in the overflow menu, a grid's Add new in its card header. Follow.ai/skills/admin-ui-component-layer.md; the product list and product edit screens are the reference. - New and reworked grids use
<admin-grid>(see Admin grids). No view builds a Kendo grid any more; do not add newkendoGrid({...})calls. - No panel loads Kendo UI, Bootstrap 4, Font Awesome or simple-line-icons at all; the vendored
wwwroot/administration/kendo/tree has been deleted. There is no Kendo compatibility layer:$.fn.kendoGridand the other Kendo jQuery plugins do not exist. A grid's API isGrandAdmin.grids.get('#grid');$('#grid').data('kendoGrid')is gone too. Upgrading a view that still uses any of it:.ai/prompts/upgrade-kendo-view.md. - No view calls Kendo UI at all. The widgets live in
admin.ui.js(Grand.SharedUIResources/adminapp/src/ui) aswindow.GrandAdmin:modal.open(target, { title, width })/modal.close(target)for popups and confirmations,tabsbehind<admin-tabstrip>, andformat/formatDate/formatNumber/htmlEncodein place ofkendo.toStringandkendo.htmlEncode. - Editors come from the shared templates, which post exactly what the request culture binds:
data-grand-numerichides the named input and keeps the posted number in it while a second input shows the formatted one;data-grand-datedoes the same next to a nativedate/datetime-local/timepicker and is seeded with an ISO value from the server;data-grand-selectis Tom Select over theSearchendpoints. Do not write the posted value of these fields from a view - read it, or go through the widget (element.grandNumeric.value()). - Keep tab partials named
CreateOrUpdate.Tab{Name}.cshtmlnext toCreateOrUpdate.cshtml. - Never render an action the controller's permission attribute does not allow — the view is not the security boundary, but a mismatch is a bug.
Admin grids
<admin-grid> (Grand.Web.Common/TagHelpers/Admin/AdminGridTagHelper.cs) renders <div id data-role="grid" data-grand-grid='{json}'> plus inert <template> elements; admin.grid.js (an adapter over Tabulator 6, built from Grand.SharedUIResources/adminapp/src/grid) turns it into the grid. HeadAdmin, HeadStore and HeadVendor load it next to admin.ui.js.
<admin-grid id="measureweight-grid"
read-url="@Url.Action("Weights", "Measure", new { area = Constants.AreaAdmin })"
create-url="..." update-url="..." destroy-url="..."
pager="Compact" edit-mode="Inline">
<grid-toolbar-create/>
<grid-text name="markAsPrimary" value="@Loc["Admin.Configuration.Measures.Weights.Fields.MarkAsPrimaryWeight"]"/>
<grid-column field="Name" title="@Loc["..."]" width="300" editor="Text"/>
<grid-column field="Ratio" title="@Loc["..."]" width="200" editor="Numeric" decimals="8"/>
<grid-column field="DisplayOrder" title="@Loc["..."]" format="{0:0}" editor="Integer"/>
<grid-column field="Id" title="@Loc["..."]" editable="false">
<cell-template>
<button type="button" class="btn btn-default btn-sm" data-grid-click="markAsPrimaryWeight">
<i data-if="IsPrimaryWeight" class="bi bi-check-lg"></i><i data-else class="bi bi-x-lg"></i>
{{ $texts.markAsPrimary }}
</button>
</cell-template>
</grid-column>
<grid-commands edit="true" destroy="true" width="200"/>
</admin-grid>
- The server contract does not change:
DataSourceRequestin,DataSourceResult {Data, Total, Errors}out, form-urlencoded POSTs serialized likejQuery.param, the antiforgery token read likeaddAntiForgeryToken, errors shown throughdisplay_kendoui_grid_error. - The tag helper fills the defaults: page size and page sizes from
AdminAreaSettingsforpager="Full"(pager="Compact"sends no paging fields, like a Kendo grid withoutpageSize), localized pager and command texts, the request culture for number and date formats, RTL from the working language. - URLs:
*-urlattributes, orcontrollerwithread-action/create-action/update-action/destroy-action, the area taken from the current route. - Conditional columns are plain
@ifaround<grid-column>. - Cell templates are markup, not code:
{{ Field }}is encoded text,{{ Field | n2 }}is formatted,{{{ Field }}}is raw HTML,data-if/data-elsehold simple conditions,data-grid-click="globalFunction"receives(dataItem, event, grid). Nothing is evaluated as JavaScript; placeholders insideon*,styleandsrcdocattributes are dropped, and URL attributes that would run script are removed. {{{ Field }}}andencoded="false"are only for markup the server builds (such asAttributeInfo). Never put@Html.Rawinside<cell-template>; pass localized text through<grid-text>and read it as{{ $texts.name }}.- Editors:
Text,Numeric(decimals; posts the culture decimal separator the model binder reads),Integer,Checkbox,Date,DateTime,Select(optionsfrom aSelectListItemlist, oroptions-urlreturning JSON;text-fieldnames the row field holding the display text),Custom(editor-nameregistered withGrandAdmin.grids.editors.register). edit-mode="Inline"gives Kendo-style row editing (Edit, then Update/Cancel);<grid-toolbar-create>adds a row;confirm-destroy="true"asks before Delete;reload-after-save="false"keeps the page after an update (create always reloads);visible-ifon<grid-commands>hides Edit/Delete per row,edit-visible-if/destroy-visible-ifnarrow each one on top of it, andempty-textis shown (muted, small) in a row left with no button - the controller still enforces access.selectable="Checkbox"adds a checkbox column whose selection survives paging:selectedIdson the grid API,on-change="fn"(e.selectedIds), thegrand-grid:selectionDOM event,clearSelection().selection-name="SelectedProductIds"names the checkboxes so the ticked rows of the page post with the surrounding form.selectable="Row"selects one row by clicking it (Kendoselectable: true):on-change="fn",grid.dataItem(grid.select()).edit-mode="Batch"edits cells in place (Kendoincell):<grid-toolbar-save/>sends the changed rows and the rows deleted meanwhile,<grid-toolbar-cancel/>restores them;batch-prefix="products"posts all rows in one request asproducts[i].Field, without it each row is posted on its own.- A remote
Selectwithoptions-filter="startswith"shows a search box that reloadsoptions-urlwith the Kendo DropDownList server filter (filter[filters][0][value], read byDataSourceRequestFilterBinder);option-labeladds the empty choice. data="@Model.Rows"withoutread-urlrenders local rows (serialized with their own property names).server-paging="false"is for read URLs that return every row (a Kendo data source withoutserverPaging): pages are cut in the browser and no paging fields are sent.on-data-boundalso runs when Tabulator renders the rows again on its own (a tab shown, columns hidden for the window width;e.rerenderedis true), so handlers that bind to row elements - the magnificPopup edit links - must be safe to run again.<grid-detail read-url="..." param="customerId:CustomerId">with nested<grid-column>elements loads a detail grid per expanded row.destroy-urlgets the same parameters,visible-ifhides the expander for master rows without details,on-data-boundruns for each detail grid, andon-detail-initon the master receivese.detailGridande.detailElement(whichGrandAdmin.grids.get(el)also finds).recursivemakes the rows of the detail grid expand to the same detail, as deep as the data goes (knowledgebase categories to their subcategories): the read URL answers the children of any row, andvisible-ifon a child count keeps the expander off the leaves.min-screen-widthhides a column below that window width;auto-bind="false"waits fortabstrip_on_tab_show.GrandAdmin.grids.get(el)(an id,#id, a selector, an element or a jQuery object) returns the API for the calls views make (dataSource.read/page/pageSize/get/data/total/remove/sync,dataItem(tr),select(),refresh());on-data-bound,on-edit,on-save,on-request-start,on-request-end,on-error,on-detail-initname global handlers.adminappsource changes neednpm run buildand the rebuilt bundle committed with them (.ai/skills/frontend-bundle-workflow.md).
Themes
- A theme copies only the views it changes; the rest resolve through the fallback view locations. See
.ai/skills/theme-creation.md. - A theme must not change view models, route names, or controller contracts.
Anti-patterns
- Business logic or repository calls in a view.
@Html.Rawon user-supplied content.- Inline
styleattributes where a theme class exists. - Copying an entire view tree into a theme.
- Editing a generated bundle by hand.