Skip to content
.NET, Frameworks (XAF & XPO), eXpressApp Framework
Branch: 19.1.3+
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
CS Source auto update [skip ci] May 14, 2019
.gitattributes first commit Mar 7, 2019
.gitignore first commit Mar 7, 2019
LICENSE Source auto update [skip ci] Apr 23, 2019
config.json Add files via upload Apr 25, 2019

ASP.NET WebForms User-Friendly URLs for Views - v19.1

How it works

The application's URLs are managed by the WebApplication.ViewUrlManager object. This object should implement the IViewUrlManager interface with two methods - GetUrl and GetViewShortcut:

public interface IViewUrlManager {
    string GetUrl(ViewShortcut shortcut, IDictionary<string, string> additionalParams = null);
    ViewShortcut GetViewShortcut();
Interface IViewUrlManager
    Function GetUrl(ByVal shortcut As ViewShortcut, ByVal Optional additionalParams As IDictionary(Of String, String) = Nothing) As String
    Function GetViewShortcut() As ViewShortcut
End Interface

GetUrl - returns a URL based on a ViewShortcut and a dictionary of additional parameters.

GetViewShortcut - returns a ViewShortcut by the current URL.

We provide the following implementations of the IViewUrlManager interface:

ViewUrlHashManager - implements the classic functionality, where URLs contain a full description of ViewShortcut parameters:

  • /Default.aspx#ViewID=Contact_ListView
  • /Default.aspx#ViewID=Contact_DetailView&ObjectKey=ContactId

ViewUrlManager - implements the built-in User-Friendly URLs mechanism:

  • /Contact_ListView/
  • /Contact_DetailView/ContactId/

In addition, you can provide a custom implementation.

Override the WebApplication.CreateViewUrlManager method to specify the application's URL Manager.

How to enable User-Friendly URLs

  1. Create a ViewUrlManager instance in the overridden CreateViewUrlManager method of the WebApplication descendant:
protected override IViewUrlManager CreateViewUrlManager() {
    return new ViewUrlManager();
Protected Overrides Function CreateViewUrlManager() As IViewUrlManager
    Return New ViewUrlManager()
End Function
  1. Call the static RouteTable.Routes.RegisterXafRoutes() method in the Application_Start method of the Global.asax file:
protected void Application_Start(Object sender, EventArgs e) {
Protected Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
End Sub


The new User-Friendly URLs feature is based on the standard routing mechanism that uses a query string and a History API. This allows you to get full page content in a single request and gives us other significant improvements. For example, you will be able to achieve the functionality described in the How to open a View specified in an external link after logging in to a Web application with the security system enabled? ticket without any customization.

User-Friendly URLs are enabled by default in a new project created using the Wizard.

Routing customization

1. How to change the default format of User-Friendly URLs

The following example shows how to add the YourCustomString prefix to the default user-friendly URL format. It removes the default routing rule (YourClass_View/KeyValue) and adds a custom one (YourCustomString/YourClass_View/KeyValue).

using System;
using System.Web.Routing;
using DevExpress.ExpressApp.Web;
protected void Application_Start(Object sender, EventArgs e) {
    RouteTable.Routes.MapPageRoute(ViewUrlManager.RouteName, "YourCustomString/{ViewID}/{ObjectKey}/", "~/Default.aspx", false, new RouteValueDictionary() { { "ObjectKey", string.Empty } });
Imports System
Imports System.Web.Routing
Imports DevExpress.ExpressApp.Web
Protected Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
    Dim routeValueDictionary As RouteValueDictionary = New RouteValueDictionary()
    routeValueDictionary.Add("ObjectKey", String.Empty)
    RouteTable.Routes.MapPageRoute(ViewUrlManager.RouteName, "YourCustomString/{ViewID}/{ObjectKey}/", "~/Default.aspx", False, routeValueDictionary)
End Sub

2. How to provide custom URLs

  1. Create a custom class that implements the IViewUrlManager interface: CustomRouteManager.cs/CustomViewUrlManager.vb.
  2. Override the CreateRouteManager method in the application's WebApplication descendant: WebApplication.cs/WebApplication.vb.

The attached example uses a model extender to allow specifying user-friendly View identifiers in the Model Editor:

For ListView:

  • /Contacts/ instead of /Contact_ListView/
  • /Tasks/ instead of /DemoTask_ListView/

For DetailView:

  • /Contact/ContactId/ instead of /Contact_DetailView/ContactId/
  • /Task/TaskId/ instead of /DemoTask_DetailView/TaskId/

Check the WebModule.cs and WebModule.vb files to see the IModelView extender's implementation.

3. How to show a View in a new window on the client side

The WebApplication.ViewUrlManager.GetUrl(viewShortcut) method allows you to obtain a View's URL by its ViewShortcut. This URL can be used as a parameter of the JavaScript method to open a new browser window. See an example in the CustomLinkController.cs and CustomLinkController.vb files.

You can’t perform that action at this time.