PathInfo

Use C1 CMS API to work with PathInfo

With classic ASP.NET pages, a URL may include the “PathInfo” part, a more friendly way of querying data than a query string.

For example:

  • Query string: www.contoso.com/Blog.aspx?year=2011
  • PathInfo: www.contoso.com/Blog.aspx/2011

When using PathInfo on the website where extensionless URLs are used (‘/Blog’ instead of ‘/Blog.aspx’), the system should have a way of distinguishing between, for example,:

www.contoso.com/Blog/2011 - where ‘Blog’ is a page and ‘2011’ is the PathInfo

and www.contoso.com/Blog/2011 - where ‘2011’ is a non-existent page

In first case, the page should be displayed by the specified URL, and in the second case, it should be redirected to the “Page not found” page or response with the 404 response code.

For this reason, C1 CMS processed such requests in the following way:

If there is a request to http://site/a/b/c/d/e, C1 CMS searches for the longest chain which is still pointing to a CMS Page:

  1. http://site/a/b/c/d/e
  2. http://site/a/b/c/d
  3. http://site/a/b/c
  4. http://site/a/b
  5. http://site/a

For example, if ‘http://site/a/b/c/’ is the CMS Page (and ‘/d/e’ is thus the path info), C1 CMS will render the page internally, and check whether any function has notified the system of using '/d/e' as the path info. If so, the page will be displayed; otherwise – “Page not found” (redirect or 404).

Plugin developers should use the following 2 static functions:

  • Composite.Core.Routing.Pages.C1PageRoute.GetPathInfo(): to get the PathInfo value
  • Composite.Core.Routing.Pages.C1PageRoute.RegisterPathInfoUsage(): to register the PathInfo usage

When configuring a hostname binding, the “Custom 404 Page” field can be used to specify the URL where to redirect to in case of the PathInfo part not being handled.