HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityDoc feedbackLog In
GitHubNuGetDev CommunityDoc feedback


In the example, the part of the URL that is `http://site/News/` is the URL to a page instance of model type `NewsContainer`. By registering a partial router for `ModelType NewsContainer`, the partial router takes care of routing the remaining part of the URL. The partial router handles routing `Sports/TheGame/`.

## Extend routing for the NewsContent type

The following example extends routing for the `NewsContainer` content type:



This code example is just one way of implementing a partial router and uses DDS as external storage and no caching, it is not meant as production-ready code.

## Implement NewsContentStore

Create a simple store to deliver `NewsContent` instances because `NewsContent` is stored outside Optimizely Content Management System (CMS) (in Optimizely Dynamic Data Store).

You also could return the routed data as `IContent` instances, where the data can be delivered through a custom content provider. Or, you can store the data in CMS so that no provider is needed and the data can be loaded or saved through `EPiServer.IContentRepository`.

In the following example, partially route URL parts like _Sports/TheGame/_ by adding a method to the store that accepts a category (that corresponds to _Sports_ in the URL example) and the name of an article (that corresponds to _TheGame_ in the URL example).



## Implement IPartialRouter

Make the partial router handle incoming requests beyond pages of type `NewsContainer`. Also, allow outgoing FURLs to be created for instances of `NewsContent`.



## Register a router

The following example initializes code that registers the partial router. 



## Register MVC controllers

In CMS, you register an MVC controller for a Model type by implementing the `EPiServer.Web.IRenderTemplate<TModel>` interface. This is done implicitly if your controller inherits `EPiServer.Web.Mvc.PageController<TPage>` or `EPiServer.Web.Mvc.BlockController<TBlock>`. The following code is for an MVC controller for `NewsContent` and `NewsContainer` that uses an extension method in the `EPiServer.Web.Routing` namespace.



## Create MVC views

To display a single news from the above controller, create a view located as _/Views/NewsContent/index.aspx_. Also, create a view for the `NewsContainer` class that lists all news with partial routed FURLs. 



## Create outgoing URLs

To create an outgoing URL for a `NewsContent` item, call the `EPiServer.Web.UrlResolver.Current.GetVirtualPathForNonContent` method. For `IContent` instances, you also can call the `GetVirtualPath` or `GetUrl` methods and pass in the reference to the content. In web forms, you can create a link in the HTML, such as _/Templates/NewsContent.aspx?id=7\_\_news_, then the FURL module calls the partial router during outgoing parsing to create an FURL for the content. The following example shows how to construct outgoing FURLs.



## Create NewsContent

The following example shows how to route to data that is stored outside CMS. Use `DynamicDataStore` to store `NewsContent`. The following code creates `NewsContent` instances and stores them in `DynamicDataStore`.