While ASP.NET applications typically use C# and HTML, they also introduce their own syntax and coding conventions, which are dependent on the specific technology and templating engine used.
Note: This style guide inherits rules from the C# Style Guide, C-Based Languages Style Guide, SGML-Based Languages, HTML5, and the Global Style Guide. This document will supersede our legacy User Controls Style Guide.
This page is a placeholder; additional content will be provided at a later date.
- Use (or extend) the ASP.NET Identity libraries for authentication (including single-sign-on), roles-based authorization, and, where practical, profile management
- If a custom database is necessary, it is preferred to write providers for the ASP.NET Identity libraries than to create a completely novel system
- If the contents of a page are not dynamic, or vary based on limited parameters, consider using
OutputCache
to improve performance OutputCache
should always use theCacheProfile
unless the parameters are truly page specific- Pages that are rarely accessed should not use output caching as it increases memory requirements
- For pages that vary by state variables (e.g., cookies, session, user profile properties, etc) use
VaryByCustom
- If page-specific code is required, it should be placed in a
CodeFile
; this is preferred toCodeBehind
, which requires pre-compilation into a centralized assembly- The name of the
CodeFile
should be the same as the page, plus.cs
; e.g., aHome.aspx
page will have aCodeFile
set toHome.aspx.cs
- Typically, page-specific code should be minimal, instead relying on centralized class libraries; this should act similar to a controller in an MVC application
- The name of the
- Make use of User Controls to parameterize and centralize repetitive elements, especially across pages
- Prefer use of the
ListView
to other repeaters; it provides complete control over markup, while also offering more convenience-features thanRepeater
- Consider creating custom
DataSourceControl
classes as part of a data access layer to simplifying querying and binding to the interface