---
title: Derive MVC route parts from a request URI
summary: Derive ASP.NET MVC-style route segments from a request URI.
status: draft
owner: saif-docgen
last_reviewed: 2026-09-15
library: SAIF.Framework.Common
reference_type: package
operation_id: OP-029
trigger: A consuming web layer needs the application, page, or controller/action name from the current request URL*
---

# Derive MVC route parts from a request URI

Derive ASP.NET MVC-style route segments from a request URI, triggered when a consuming web layer needs the application, page, or controller/action name from the current request URL*.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-029 |
| **Trigger** | A consuming web layer needs the application, page, or controller/action name from the current request URL* |
| **Inputs** | `Uri` |
| **Outputs** | `string` |
| **Primary components** | ``UriExtensions.ApplicationName`, `PageName`, `ControllerAndActionName`` |
| **Entry point** | `Common/SAIF.Common/Extensions/UriExtensions.cs` |

## Steps

1. `ApplicationName`: if the URI is null or has fewer than 2 segments, return `string.Empty`; otherwise return segment 1 with `/` removed — the IIS virtual-directory / application name. ([BR-068](../business-rules.md#br-068-the-application-name-is-url-segment-1))
2. `PageName`: guard with `Enforce.ArgumentNotNull(uri, "uri")` (throws on null, unlike the other two members), then return segment 2 with `/` removed, or the literal "Index" when there are 2 or fewer segments. ([BR-069](../business-rules.md#br-069-the-page-name-is-url-segment-2%2C-defaulting-to-%22index%22-when-absent), [BR-039](../business-rules.md#br-039-a-guarded-argument-must-not-be-null))
3. `ControllerAndActionName`: seed the result with the default "Home/Index" and return that immediately if the URI is null. ([BR-070](../business-rules.md#br-070-the-default-controller%2Faction-route-is-home%2Findex))
4. With more than 3 segments, concatenate segments 2 and 3 (controller + action, each retaining its trailing `/`). ([BR-070](../business-rules.md#br-070-the-default-controller%2Faction-route-is-home%2Findex))
5. With exactly 3 segments, concatenate segment 2 with the literal "Index" — the default action. ([BR-070](../business-rules.md#br-070-the-default-controller%2Faction-route-is-home%2Findex))

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start(["Caller requests<br>a route part"]) --> D1{"ApplicationName: URI null<br>or fewer than 2 segments?"}
	D1 -->|Yes| S1a([Return empty string])
	D1 -->|No| S1b(["Return segment 1<br>minus '/'"])
	S1a --> S2
	S1b --> S2["PageName: guard uri<br>not null (throws if null)"]
	S2 --> D2{"PageName: 2 or<br>fewer segments?"}
	D2 -->|Yes| S2a(["Return literal 'Index'"])
	D2 -->|No| S2b(["Return segment 2<br>minus '/'"])
	S2a --> S3
	S2b --> S3["ControllerAndActionName: seed<br>result as 'Home/Index'"]
	S3 --> D3{"URI is null?"}
	D3 -->|Yes| S3a(["Return 'Home/Index'"])
	D3 -->|No| D4{"More than<br>3 segments?"}
	D4 -->|Yes| S4(["Return segment 2<br>+ segment 3"])
	D4 -->|No| D5{"Exactly<br>3 segments?"}
	D5 -->|Yes| S5(["Return segment 2<br>+ literal 'Index'"])
	D5 -->|No| End(["Return default<br>'Home/Index'"])
```

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.

## Sources
- `Common/SAIF.Common/Extensions/UriExtensions.cs`
