33 KiB
AGENTS.md
Project identity
This project is Plataforma de Desarrolladores Agua Hillo.
It is an ASP.NET WebForms application using C# and .NET Framework 4.8 or 4.8.1.
Do not convert this project to:
- ASP.NET Core
- Razor Pages
- MVC Core
- Blazor
- Minimal APIs
- Angular-only app
- Web API-only app
ASP.NET WebForms must stay on .NET Framework. If a command, package, or template requires ASP.NET Core, do not use it for this project.
Main goal
Create a clean WebForms starter project from zero, keeping the same Metronic visual style and only the necessary bundle methods used by the master page and login page.
The project must use a contract/service structure so pages, master page, login, menu, user session, and future modules do not connect directly to database classes.
Target architecture:
ASPX / Master Page / User Controls
↓
Contracts
↓
Services
↓
Repositories / SQL helpers
↓
Database
Language rules
- All new code must be C#.
- Do not add VB.NET files.
- Do not add
.vbfiles to the active project. - Old VB files may exist only as migration reference files using
.vb.txt. - Do not use VB comment syntax in C# files.
- Do not use JavaScript/CSS/Powershell comments as C# comments.
Source code readability rules
All generated or modified source code must be formatted for human maintenance.
- Do not compress multiple controls, HTML elements, CSS rules, SQL clauses, assignments, conditions, or statements onto one line merely to reduce file length.
- Use consistent indentation and line breaks that make nesting and control flow visible.
- Put independent C# statements on separate lines. Expand non-trivial
if, loops, object initializers, method calls, and methods across multiple lines. - In ASPX/HTML, place nested elements and server controls on separate indented lines. Keep attributes readable; wrap long declarations across lines.
- Format CSS with one declaration per line for page-specific styles. Format JavaScript and SQL using the same readability principle.
- Prefer clear diffs and easy future editing over compact generated output.
- The command rule requiring one-line PowerShell or terminal commands applies only to commands. It does not apply to C#, ASPX, HTML, CSS, JavaScript, SQL, XML, or configuration source.
Agent instruction file maintenance rules
- Before modifying
AGENTS.mdor any complementaryAGENTS_*.mdfile, read the existing file and apply only the smallest required addition or correction. - Do not rewrite or replace an entire agent instruction file unless the user explicitly requests a complete rewrite.
- Preserve existing user-authored rules, terminology, capitalization, examples, and formatting outside the requested change.
- When adding a rule, first verify whether an equivalent or conflicting rule already exists and update only the relevant section.
Command rules
When giving commands for this project:
- Prefer PowerShell, Developer PowerShell, or Visual Studio Package Manager Console commands.
- Commands must be written in one line.
- Do not use PowerShell line continuation with backticks.
- Do not suggest
dotnet new webformsbecause WebForms is not supported by the .NET CLI as an ASP.NET Core project. - If a WebForms project must be created from command line, use Visual Studio/MSBuild-compatible project files or create the project through Visual Studio using ASP.NET Web Application (.NET Framework).
- Target framework must be
.NET Framework 4.8or.NET Framework 4.8.1.
Recommended project creation path:
mkdir "C:\Proyectos\Agua de hermosillo\Plataforma de Desarrolladores"
cd "C:\Proyectos\Agua de hermosillo\Plataforma de Desarrolladores"
Then create/open the WebForms project in Visual Studio 2022 as:
ASP.NET Web Application (.NET Framework) → Web Forms → C# → .NET Framework 4.8/4.8.1
Project folder rules
Use this base structure:
SIG.Web/
App_Code/
Infrastructure/
Sql/
Repositories/
Security/
Utilities/
Contracts/
Models/
Services/
Styles/
Scripts/
Metronic/
Site.master
Site.master.cs
Login.aspx
Login.aspx.cs
Inicio.aspx
Inicio.aspx.cs
BundleConfig.cs
Global.asax
Global.asax.cs
Web.config
Rules:
- The active application uses the ASP.NET Web Site runtime-compilation model.
- Shared C# source belongs in the exact special folder
App_Code. - Pages, master pages, controls, handlers, and
Global.asaxuseCodeFileor source compiled fromApp_Code; do not introduce newCodeBehinddependencies onSIG.Web.dll. - Keep third-party and external assemblies in
bin, but do not build or deploy a project assembly namedSIG.Web.dll. - Do not place database access directly inside
.aspx.cs,.ascx.cs, orSite.master.cs. - Database-related helpers go under
App_Code/Sqlor a clearly named SQL/data folder. - Business access goes through
ContractsandServices. - The active Web Site does not use explicit project compilation entries; C# files under
App_Codecompile automatically at runtime.
Asset folder rules
The following folders are legacy visual dependencies and must be copied as complete folders:
Styles/
Scripts/
Metronic/
Do not replace Metronic with Bootstrap-only layout. Do not upgrade Metronic unless the user explicitly asks. Do not remove old scripts just because they look unused; only remove references from bundles when they are not used by the master/login flow.
Bundle rules
The project must implement only the bundle methods needed by the current Site.master and login page.
Do not bring every old bundle method from the legacy project. Do not add unused bundle groups just because they existed before. Do not add duplicate bundle keys. Do not add empty bundle methods.
Allowed current bundle keys are the ones actually rendered by master/login, especially:
~/bundles/modernizr
~/bundles/scripts
~/bundles/highcharts
~/Metronic/assets/global/scripts/JSV1
~/Metronic/assets/global/css/cssV1
WebForms/AjaxControlToolkit support bundles are allowed only when referenced by ScriptManager or required by WebForms controls:
~/bundles/jquery
~/bundles/WebFormsJs
~/bundles/MsAjaxJs
~/Content/AjaxControlToolkit/Styles/Bundle
Rules:
- If
Site.masterorLogin.aspxdoes not render a bundle, do not add it. - If a bundle exists only for old pages not migrated yet, leave it out until the page needs it.
- Prefer preserving original asset paths from
Styles,Scripts, andMetronic. - Use
CssRewriteUrlTransformfor CSS bundles that reference fonts, images, or relative URLs. - Do not register CSS/JS from server controls when the style/script is global; use
BundleConfigand the master page.
WebForms page rules
All normal .aspx pages must use Site.master, except the login page.
Normal pages:
- Must include
MasterPageFile="~/Site.master". - Must not include
<html>,<head>,<body>, or<form>. - Must use
<asp:Content>controls. - Should inherit from
ClsPaginaBaseor the current C# page base class. - Must not connect directly to SQL classes.
- Must call contracts/services for data, authentication, permissions, catalogs, menus, and user context.
Public registration exception:
Pages/Security/RegistroCliente.aspx,RegistroPendiente.aspxandVerificarCorreo.aspxmay be standalone public pages with their ownform runat="server".RegistroCliente.aspxkeeps its two-step draft in encrypted ViewState and persists only after all client/company validations pass.- All persistence continues through contracts/services/repositories and stored procedures.
Login page:
- Is the only page allowed to have its own full HTML structure.
- May inherit from
System.Web.UI.Pageor its own login base class. - Must not inherit from
ClsPaginaBaseif that base class requires an authenticated session. - Must use
IAuthContractor the current auth contract. - Must create a dummy session until real authentication is implemented.
- Must not hardcode real database login logic in
Login.aspx.cs.
Important naming rule:
- Do not create both
Login.aspxandLogIn.aspx. - If the starter already uses
LogIn.aspx, keep that name and keepWeb.configconsistent. - If creating from scratch, prefer
Login.aspx, but updateWeb.config, redirects, and links consistently.
Master page rules
Site.master owns the main HTML structure.
Rules:
Site.masterowns the only main<form runat="server">.Site.mastermust keep the Metronic layout structure.- Keep the sidebar/header/page-content structure similar to the original Metronic project.
- Do not restore the hidden search box from the old header.
- Keep the actions button if it exists in the selected master layout.
- Do not hardcode real user/menu database logic inside
Site.master.cs. - User data must come from a contract/service.
- Menu data must come from a contract/service.
- Breadcrumb/title/layout data must come from a contract/service when dynamic.
- Do not use
<title id="Titulo" runat="server">. - Prefer
<title><%: Page.Title %></title>. - If a generated starter currently uses a title literal, replace it with
Page.Titleunless there is a specific reason to keep the literal.
Current preferred contracts:
IAuthContract
IUserSessionContract
IMenuContract
IMasterPageContract
If old names such as IUserContextProvider or IMenuProvider exist, migrate them to the current contract naming or create adapters. Do not keep two competing naming systems.
ContentPlaceHolder rules
Site.master must use short placeholder IDs.
Preferred final placeholder IDs:
H = page-specific head/CSS content
C = main page content
J = page-specific JavaScript
Example in Site.master:
<asp:ContentPlaceHolder ID="H" runat="server" />
<asp:ContentPlaceHolder ID="C" runat="server" />
<asp:ContentPlaceHolder ID="J" runat="server" />
Example in a normal page:
<asp:Content ID="ContentHead" ContentPlaceHolderID="H" runat="server">
</asp:Content>
<asp:Content ID="ContentMain" ContentPlaceHolderID="C" runat="server">
</asp:Content>
<asp:Content ID="ContentScripts" ContentPlaceHolderID="J" runat="server">
</asp:Content>
If the generated starter currently has HeadContent, MainContent, or ScriptsContent, rename them to H, C, and J before adding more pages.
Do not mix placeholder naming systems in the same project.
WebForms tab and page-state rules
- Register AjaxControlToolkit once in
Web.configundersystem.web/pages/controlswith the exact prefixajax; do not add<%@ Register ... %>directives for it in individual pages. - AjaxControlToolkit controls must use the
ajax:prefix, for exampleajax:TabContainerandajax:TabPanel; do not useajaxToolkit:or another page-specific prefix. - Tabs in WebForms pages must use
ajax:TabContainerandajax:TabPanel; do not build page tabs with Bootstrapnav-tabs, custom hidden panels, or JavaScript-only tab switching. - Use the
ScriptManagerowned bySite.masterand the existing AjaxControlToolkit resources. Do not add anotherScriptManageror duplicate Toolkit scripts/styles. - Server-side page state such as current entity keys, selected child keys, editing mode, flags, and the active tab must be stored in typed
ViewStateproperties when it must survive postback. - Do not add
asp:HiddenFieldmerely to preserve server-side state across postbacks. A hidden field is allowed only when client-side JavaScript must read or change the value. - Hidden-field values are client-controlled and must never be trusted for authorization or sensitive decisions; validate them again on the server when their use is unavoidable.
- Keep ViewState values small and serializable. Do not store database connections, commands, readers, services, repositories, or unnecessarily large result sets in ViewState.
- ViewState property and key names must identify the entity and purpose, for example
CveFraccionamientoActualandCveFraccionamientoEtapaActual.
Login and session rules
Authentication must go through a contract.
Required flow:
Login.aspx.cs
↓
IAuthContract
↓
DummyAuthContract now, real AuthService later
↓
IUserSessionContract
↓
Session user
Initial login may be dummy.
Dummy session user should be safe and clearly fake, for example:
UserId: 15
CompanyId: 1
RoleId: 1
RoleName: Administrador
CompanyName: Empresa Demo
DisplayName: Usuario Demo
Rules:
- Dummy login may accept any non-empty username and password during starter setup.
- Mark dummy authentication clearly in code comments.
- Do not mix real SQL authentication with dummy authentication in the same class.
- When real login is implemented, create a new service such as
SqlAuthContractorAuthService. - Do not store passwords in session.
- Do not log raw passwords.
- Use Forms Authentication if staying with classic WebForms auth.
Contract rules
Contracts belong in /Contracts.
Current minimum contracts:
Contracts/IAuthContract.cs
Contracts/IUserSessionContract.cs
Contracts/IMenuContract.cs
Contracts/IMasterPageContract.cs
Suggested future contracts:
Contracts/IPermissionContract.cs
Contracts/INotificationContract.cs
Contracts/ICatalogSearchContract.cs
Contracts/IAuditContract.cs
Contracts/ICurrentCompanyContract.cs
Rules:
- Pages call contracts, not SQL classes.
- Master page calls contracts, not SQL classes.
- Login calls contracts, not SQL classes.
- Contracts must return models, DTOs, or result objects, not raw
DataTableunless migrating legacy code. - If legacy
DataTableis required, isolate it behind a contract and document why.
Repository ownership rules
Repository ownership is determined by the data domain and stored-procedure prefix, not by the page or feature that currently consumes the data.
- Procedures named
PA_Gral_*belong behind contracts and repositories underContracts/GeneralandRepositories/General. - General catalogs such as states, countries, municipalities, neighborhoods, and postal codes must not be placed in a security, registration, sales, or page-specific repository.
- A feature service such as public registration may orchestrate both its feature repository and
IGeneralCatalogRepository, but it must not move general catalog access into the feature repository. - Apply the same ownership rule to future procedure families:
PA_Sis_*belongs to security/system infrastructure,PA_Tra_*to procedures,PA_Vta_*to sales, and so on.
Database executor ownership rules
IDbExecutor,DbExecutor,StoredProcedureCommand,IDbCommand, and direct stored-procedure execution may only be used inside classes underRepositoriesor repository database infrastructure.- Services must not reference or receive
IDbExecutor, create database commands, execute readers, or call stored procedures directly. - A service that needs persisted data must depend on a repository contract. The concrete repository receives
IDbExecutorand owns parameter configuration and result mapping. - Keep the
DbExecutorimplementation underRepositories/Database; do not place it underServicesor expose it publicly throughAppServices.
Service rules
Services belong in /Services.
Current starter services may include:
Services/ContractRegistry.cs
Services/DummyAuthContract.cs
Services/UserSessionContract.cs
Services/DummyMenuContract.cs
Services/MasterPageContract.cs
Rules:
ContractRegistrymay be used as a simple manual dependency resolver for WebForms.- Do not introduce a complex dependency injection framework unless required.
- Services may depend on SQL helpers/repositories.
.aspx.csfiles should be thin and delegate work to services.- Keep dummy services separate from SQL-backed services.
- Services own application transactions when one business operation performs one or more repository mutations.
- Use
TransactionLogicinside ausingblock around the repository calls and invokeCommit()only after every required repository result succeeds. - Pages and repositories must not create, commit, roll back, or dispose application transactions.
- Repositories participate through the ambient
TransactionScope; connection strings used for transactional work must not setEnlist=false. - Select
TransactionScopeOption, isolation level, and timeout in the service according to the business operation. UseRequiresNeworSuppressonly when that behavior is intentional and documented by the call site. - Do not include slow external operations such as SMTP or HTTP calls inside a database transaction.
Model rules
Models belong in /Models.
Current starter models may include:
Models/AppUser.cs
Models/LoginResult.cs
Models/MenuItemModel.cs
Models/MasterLayoutModel.cs
Models/BreadcrumbItem.cs
Rules:
- Use models to move data between contracts and WebForms pages.
- Do not pass anonymous objects across layers.
- Do not expose SQL connection classes or
SqlDataReaderfrom services to pages. - Keep models simple and serializable when possible.
Database and SQL structure rules
All database connection structure must be centralized under App_Code/Sql or an equivalent SQL/data folder.
Current starter SQL structure:
App_Code/Sql/ConnectionNames.cs
App_Code/Sql/IConnectionStringProvider.cs
App_Code/Sql/WebConfigConnectionStringProvider.cs
App_Code/Sql/SqlConnectionFactory.cs
App_Code/Sql/SqlQueryExecutor.cs
Rules:
- Define connection names in one place.
- Read connection strings from
Web.config. - Do not hardcode connection strings in pages, master, controls, or services.
- Do not create
SqlConnectiondirectly in.aspx.cs. - Do not create
SqlCommanddirectly in.aspx.cs. - Use repositories or SQL executor classes behind contracts.
- All application database reads and writes must use stored procedures; inline SQL in C# is prohibited.
- Mandatory: read and follow
AGENTS_STORED_PROCEDURES.mdfor naming, output parameters, TRY/CATCH, logging, transactions, and physical deletion. - Mandatory: read and follow
AGENTS_DATA_READER_MAPPING.mdfor object, list,DataTable, andJArrayresult mapping. - Mandatory: read and follow
AGENTS_DATABASE_ERROR_LOGGING.mdfor safe parameter logging and reproducible stored-procedure calls. - Mandatory: read and follow
AGENTS_PAGE_STRUCTURE.mdfor thePages/Modulo/location of all new WebForms pages. - Mandatory: read and follow
AGENTS_WEBFORMS_PARTIAL_POSTBACKS.mdfor the single master form, ScriptManager ownership, UpdatePanel usage, and partial-postback rules. - Mandatory: read and follow
AGENTS_JAVASCRIPT_INITIALIZATION.mdfor per-element initialization flags, global event guards, and idempotent control setup after partial postbacks. - Mandatory: read and follow
AGENTS_CATALOG_STRUCTURE.mdfor catalog titles, breadcrumbs, actions, filters, indicators, grids, quick-create modals, and detail pages. - Mandatory: read and follow
AGENTS_DOCUMENT_STORAGE.mdfor document folders, client access validation, protected file retrieval, and GIS file naming. - Keep stored procedure names centralized.
- Repositories must use
CommandType.StoredProcedureand parameterized inputs/outputs. - Never concatenate raw user input into SQL.
- The database default collation and general text columns must use
Modern_Spanish_CS_AS. - Columns named
Codigo, beginning withCodigo, or containing a real user login identifier such asNombreUsuario,UsuarioPortal, orAcum_PortalUsuariomust useModern_Spanish_CI_AS. AgenteUsuariois browser/device metadata, not a login identifier, and must use the generalModern_Spanish_CS_AScollation.- Do not use
Modern_Spanish_CS_AI.
Recommended Web.config connection string pattern:
<connectionStrings>
<add name="DefaultConnection" connectionString="..." providerName="System.Data.SqlClient" />
<add name="SecurityConnection" connectionString="..." providerName="System.Data.SqlClient" />
<add name="ReportingConnection" connectionString="..." providerName="System.Data.SqlClient" />
</connectionStrings>
Base page rules
Normal pages should inherit from a C# base page.
Preferred base class:
App_Code/Infrastructure/ClsPaginaBase.cs
If the starter currently has WebFormsPageBase.cs, either:
- rename it to
ClsPaginaBase.cs, or - keep
WebFormsPageBaseand update this AGENTS.md/project rules consistently.
Do not keep both base classes doing the same job.
Base page responsibilities:
- Validate authenticated session.
- Expose current user from
IUserSessionContract. - Provide helper methods for messages, redirects, and permissions.
- Avoid database access.
- Avoid page-specific business logic.
Global.asax rules
Global.asax / Global.asax.cs should:
- Register bundles through
BundleConfig.RegisterBundles(BundleTable.Bundles). - Configure basic application startup.
- Avoid business logic.
- Avoid direct database startup queries unless absolutely required.
If OWIN is not used, prevent startup errors by adding this to Web.config:
<add key="owin:AutomaticAppStartup" value="false" />
Do not add OWIN packages unless the project actually needs OWIN.
Web.config rules
Web.config must stay compatible with ASP.NET WebForms on .NET Framework 4.8/4.8.1.
Rules:
- Use Forms Authentication unless a different auth system is explicitly requested.
- Allow anonymous access only to the login page and required static assets.
- Do not add ASP.NET Core middleware settings.
- Do not add unsupported
.NET Coreconfig sections. - Do not add CodeDom provider entries unless the matching NuGet package is installed.
- If this error appears:
No se pudo ubicar el tipo de proveedor CodeDom Microsoft.CodeDom.Providers.DotNetCompilerPlatform..., either install the exact package version or remove/fix thesystem.codedomsection. - Keep MIME mappings for fonts such as
.woffand.woff2when Metronic requires them.
OWIN rule
If the application shows this error:
No assembly found containing an OwinStartupAttribute
And the project does not use OWIN, add this in appSettings:
<add key="owin:AutomaticAppStartup" value="false" />
Do not create an empty OWIN startup class just to silence the error unless OWIN is actually required.
Site.master rendering rules
The master page should render bundles and scripts in this general order:
Inside <head>:
<%: Scripts.Render("~/bundles/modernizr") %>
<%: Styles.Render("~/Content/AjaxControlToolkit/Styles/Bundle") %>
<%: Styles.Render("~/Metronic/assets/global/css/cssV1") %>
<asp:ContentPlaceHolder ID="H" runat="server" />
Inside <form> near the top:
<asp:ScriptManager ID="TSM" runat="server" />
<%: Scripts.Render("~/bundles/scripts") %>
Before closing </form>:
<%: Scripts.Render("~/Metronic/assets/global/scripts/JSV1") %>
<%: Scripts.Render("~/bundles/highcharts") %>
<asp:ContentPlaceHolder ID="J" runat="server" />
Rules:
- Do not render the same script twice.
- Do not render JQuery twice.
- Keep
ScriptManagerif AjaxControlToolkit, UpdatePanel, or WebForms AJAX is used. - Keep
TSM_AsyncPostBackErroronly if implemented in code-behind. - Remove or implement any event handler referenced by markup.
Header/menu rules
The master header must preserve the selected Metronic layout.
Rules:
- Keep user dropdown.
- Keep logout option.
- Keep actions button when present.
- Do not restore the hidden/old search box from legacy header.
- Sidebar menu must be built from
IMenuContract. - Do not build the menu from SQL inside
Site.master.cs. - Menu items should use
MenuItemModelor an equivalent model. - Encode text output when generating HTML menu strings.
- Module visibility and page access are separate concerns:
Sis_Modulos.Visiblecontrols whether an item is shown in the menu, but it must not deny direct page access. PA_Sis_PaginaAccessCheckmust validate role assignment,PuedeVer, active state, and URL. It must not requireSis_Modulos.Visible = 1.
Page title and breadcrumb rules
Page title and breadcrumb should be handled consistently.
Rules:
- Use
Page.Titlefor the browser title. - Use a master/layout model for visible page title and breadcrumb.
- Do not hardcode global breadcrumb logic in every page.
- Normal pages may set page title in
Page_Loador via properties.
Preferred model:
MasterLayoutModel
PageTitle
Breadcrumbs
CurrentUser
MenuItems
Security rules
- Do not store passwords in code, comments, Web.config examples, or session.
- Do not expose real connection strings in committed files.
- Use dummy values in examples.
- Use parameterized SQL.
- Validate uploaded files by extension, MIME type, and size when uploads are later added.
- Avoid writing raw exception details to the user in production.
- Keep
customErrors mode="Off"only for local development.
Error handling rules
Controlled outcomes and technical failures must use different logs.
-
@ErrorTipo = 1, SQL exceptions, timeouts, contract failures, and unexpected exceptions go to the main technical log. -
@ErrorTipo = 2is a controlled warning. It must not be written to the main technical log. -
Controlled warnings go to daily compact files under
~/log/controlled. -
Controlled log files retain only the current day and the previous two days. The retention is configured with
ControlledLogRetentionDays = 3. -
Explicit controlled throws must use
ControlledApplicationException; do not classify arbitraryExceptionorInvalidOperationExceptioninstances as controlled. -
Controlled logs record date, source, procedure, URL, and friendly message, but omit full stack traces and replay SQL to remain compact.
-
A controlled exception must still return a friendly result to the page and must never be presented as an unexpected application failure.
-
Handle null session user cleanly and redirect to login.
-
Handle failed login with a friendly message.
-
Handle async postback errors through
ScriptManager.AsyncPostBackErroronly if the handler exists. -
Avoid infinite loading states in JavaScript controls.
-
For AJAX/server search controls, use client and server timeouts.
-
Recommended default search timeout: about 20 to 30 seconds unless the user asks otherwise.
Action availability and feedback rules
- Do not disable a button or primary action only because a business prerequisite is missing, such as an unassigned client or an empty related catalog.
- Keep the action available by default; when the user clicks it, validate the prerequisite and show a clear message explaining why the operation cannot continue and what must be done next.
- Never leave a disabled action without an immediately visible explanation.
- Before adding
Enabled="false", the HTMLdisabledattribute, or an equivalent disabled CSS/JavaScript state to a catalog or page action, ask the user whether disabling is acceptable or whether a message, modal, link, or other alternative should be used. - A transient disabled state used only while a request is being processed to prevent duplicate submissions is allowed, but the action must be restored when processing finishes.
Grid display rules
- Every new or modified
asp:GridViewmust declareGridLines="None". - Its
CssClassmust include the exact utility classWidthallso the grid uses the full available width. - Do not add
table-borderedto a GridView. Existing visual classes such astable,table-striped, andtable-hovermay be retained when appropriate. - Keep GridView declarations and their columns expanded and indented according to the source code readability rules.
- Detail-page navigation from a GridView or list must use
asp:HyperLinkor another real link withNavigateUrl; do not useLinkButton,RowCommand, or a postback only to open a detail page. - URL-building variables and helpers must describe the row entity, for example
cveFraccionamiento,fraccionamientoDetalleUrl, orGetFraccionamientoDetalleUrl. Avoid generic names such asid,itemUrl, ordetailUrlwhen the entity is known.
JavaScript and CSS rules
- Global scripts/styles must be registered in
BundleConfigand rendered by master. - Page-specific scripts go in placeholder
J. - Page-specific CSS/head content goes in placeholder
H. - Do not inline large JavaScript blocks in
.aspxunless page-specific and small. - Do not remove existing custom legacy files unless the user asks.
- Fix null
addEventListenererrors by checking that the element exists before attaching events. - Avoid blocking Ctrl+V unless a specific feature requires it.
User control rules
If server controls are migrated:
- Prefer C# classes under
App_Code/SigControlswhen creating reusable server controls. - Do not mix WebForms
.ascxuser controls with App_Code server-control classes unless there is a clear reason. - Do not register global CSS/JS from the control when master bundles already include them.
- Controls should expose properties/events and avoid direct SQL access.
- Controls should call contracts/services when they need data.
PDF viewer migration rules
If the PDF viewer is added to this project later:
- Implement it in C#.
- Prefer
App_Code/SigControlsfor server controls. - Do not add VB files.
- Do not use
/* */comments in VB reference files; VB references must remain.vb.txtonly. - Keep global PDF viewer CSS/JS references in bundles.
- Do not register duplicate resources from the control and master at the same time.
- Session or temp-folder PDF storage must be explicit and centralized.
Home page rules
Use only one active home page convention.
For local development, the canonical home URL is:
http://localhost:52706/Inicio.aspx
The application root must be equivalent and redirect explicitly to that page:
http://localhost:52706/ -> http://localhost:52706/Inicio.aspx
Keep the root redirect and the Inicio.aspx default document consistent. Do not introduce another startup page.
Allowed options:
Default.aspx
Inicio.aspx
Rules:
- Do not keep both as competing entry pages.
- If using
Inicio.aspx, redirectDefault.aspxtoInicio.aspxor update Forms Authentication default URL. - If using
Default.aspx, keep Web.config and menu links pointing toDefault.aspx. - The home page must use
Site.master.
File delivery rules for this project
When generating a single downloadable file:
- If the file is
.jsor.cssand it is not inside a ZIP, append.txtto the filename. - Example:
custom.js.txt,styles.css.txt. - If the file is inside a ZIP, keep the real extension
.jsor.css. - For project-level delivery, prefer ZIP files.
What not to add yet
Do not add the following until the user explicitly asks:
- Real SQL login implementation
- Full permission system
- Notifications
- Web Push
- PDF viewer
- BuscadorCatalogo
- DropdownGrid
- PorcentajeBox
- Angular
- APIs
- Background jobs
- OWIN
- Entity Framework
- Dependency injection framework
- New Metronic version
The starter must stay small and focused: commands, master page, login, contracts, dummy user session, bundle structure, copied assets, and centralized SQL foundation.
Current implementation checklist
When modifying or regenerating the project, verify:
- Project targets .NET Framework 4.8 or 4.8.1.
- All new code is C#.
- No active
.vbfiles were added. Styles,Scripts, andMetronicwere copied as-is.BundleConfig.cscontains only bundles rendered by master/login or required by WebForms AJAX.Site.masterowns the only main form.- Normal pages use
Site.master. - Normal pages do not contain full HTML structure.
- Login is the only standalone full HTML page.
- User/session data comes from
IUserSessionContract. - Login uses
IAuthContract. - Menu comes from
IMenuContract. - Master layout data comes from
IMasterPageContract. - SQL connection helpers are centralized under
App_Code/Sql. - Pages do not directly instantiate SQL connections.
- Placeholder IDs are
H,C, andJ. - No hidden old search box was restored.
- Actions button is preserved when present in the selected layout.
Web.configlogin URL matches the actual login page filename.- No duplicate
Login.aspx/LogIn.aspxpages exist. - No OWIN startup error exists, or OWIN automatic startup is disabled.
- No missing CodeDom provider error exists.
Preferred next evolution
After the starter works, the safest growth path is:
- Replace dummy login with SQL-backed
IAuthContract. - Replace dummy menu with SQL-backed
IMenuContract. - Add permission contract.
- Add base page authorization checks.
- Add reusable controls one by one.
- Add catalog search and UI helpers.
- Add PDF viewer only after the base shell is stable.
Keep every new feature behind contracts so the WebForms UI remains thin and easier to migrate later if needed.