100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
.NET Framework

Navigation Controls

See how ASP.NET Web Forms handles site navigation through the Web.sitemap file, SiteMapPath, Menu, and TreeView controls, plus programmatic redirection.

Web Forms ControlsIntermediate9 min readJul 10, 2026
Analogies

ASP.NET Web Forms includes a site-map-driven navigation system built around a single XML file, typically named Web.sitemap, that describes the hierarchical structure of a site's pages as nested siteMapNode elements with title, description, and url attributes. Three controls consume this structure without any manual wiring: SiteMapPath renders a breadcrumb trail from the site root to the current page, Menu renders a static or dynamic drop-down navigation menu, and TreeView renders an expandable hierarchical tree, and all three can bind either to the default SiteMapDataSource or to any other hierarchical data source.

🏏

Cricket analogy: Web.sitemap describing a nested page hierarchy is like an ICC tournament bracket file listing groups, then knockout rounds, then the final, with every match node just waiting to be rendered as a bracket graphic.

SiteMapPath, Menu, and TreeView

SiteMapPath needs almost no configuration beyond dropping the control onto a page — it automatically walks up from the current page's node in Web.sitemap to the root and renders each ancestor as a clickable link separated by a configurable PathSeparator. Menu and TreeView both support binding to a SiteMapDataSource via DataSourceID, and each offers StaticDisplayLevels or ExpandDepth-style properties to control how much of the hierarchy renders immediately versus on interaction, along with template properties like StaticMenuItemStyle or NodeStyle for full visual customization of each level.

🏏

Cricket analogy: SiteMapPath automatically walking up to the root is like a scorecard app auto-generating the breadcrumb 'ICC World Cup > Semi-Final > India vs Australia' without a developer hardcoding each stage.

aspx-xml
<!-- Web.sitemap -->
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
    <siteMapNode url="~/Default.aspx" title="Home">
        <siteMapNode url="~/Products/Default.aspx" title="Products">
            <siteMapNode url="~/Products/Electronics.aspx" title="Electronics" />
            <siteMapNode url="~/Products/Books.aspx" title="Books" />
        </siteMapNode>
        <siteMapNode url="~/About.aspx" title="About Us" />
    </siteMapNode>
</siteMap>

<!-- On any content page -->
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
<asp:SiteMapPath ID="SiteMapPath1" runat="server" PathSeparator=" &gt; " />
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" ExpandDepth="1" />
<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1"
    Orientation="Horizontal" StaticDisplayLevels="1" />

Programmatic Navigation

Beyond declarative navigation controls, code-behind moves users between pages with Response.Redirect(url), which sends an HTTP 302 to the browser and starts a brand-new request/response cycle (losing the current page's state unless explicitly passed via query string or Session), or with Server.Transfer(url), which switches execution to another page entirely on the server without a round trip to the browser, preserving the current request's Form and QueryString collections but leaving the browser's address bar unchanged, which can be confusing for bookmarking. Server.Transfer also does not run through IIS request filtering the way a fresh Redirect request would, so it's generally reserved for same-application forwarding after already-completed permission checks, not for cross-application or cross-domain jumps.

🏏

Cricket analogy: Response.Redirect is like a broadcast fully cutting to a different channel's live feed, with the viewer's remote (browser address bar) now showing that new channel, while Server.Transfer is like an internal studio switch to a different camera feed without the viewer's channel display ever changing.

Server.Transfer preserves the current Form and QueryString collections but does not update the browser's URL, which breaks bookmarking and can surprise users who expect the address bar to reflect where they actually landed. It also skips any URL-based security or logging that depends on a fresh request hitting IIS, so it should only be used for trusted, same-application forwarding after authorization has already been checked.

  • Web.sitemap defines a site's page hierarchy as nested siteMapNode elements consumed by navigation controls.
  • SiteMapPath automatically renders a breadcrumb trail from the site root to the current page.
  • Menu and TreeView bind to SiteMapDataSource (or other hierarchical sources) for drop-down and expandable tree navigation.
  • StaticDisplayLevels and ExpandDepth control how much of the hierarchy renders immediately versus on interaction.
  • Response.Redirect issues a browser round trip (HTTP 302) and updates the address bar; state must be passed explicitly.
  • Server.Transfer switches execution server-side without a round trip, preserving Form/QueryString but not updating the URL.
  • Server.Transfer is best reserved for same-application forwarding after authorization checks have already passed.

Practice what you learned

Was this page helpful?

Topics covered

#NETFramework#ClassicASPNETWebFormsWebPagesStudyNotes#MicrosoftTechnologies#NavigationControls#Navigation#Controls#Site#Web#StudyNotes#SkillVeris