In this tutorial, you will learn how to get the action, controller and all the tag data directly out of the HTTP Context object within an Episerver powered website page request. Querying the data directly from the request object should only be used when you have a very specific need. In my instance, I was implementing a partial fragment cache for all blocks that were accessed at the beginning of the page request life-cycle.

Accessing The Data In A Controller

If you want to access this type of data within a view, you can use the RouteData helper. This first snippet will get the current action name:

This code will return the current controller name:

Finally, you can return any rendering tags associate with the request like this:

This will return the value Default if none are set 💥

Accessing The Data In A View

You may also want to access this type of data within a view. Adding code in a view is bad practice, however, you can create a custom HTML helper to return this data for you. The skeleton code to create this helper is shown below:

Getting access to the current action is done using this command:

Getting access to the current controller is done using this command:

Getting access to the any rendering tags is done using this command:


You are now an Episerver routing master 🤘. In most situations, Episerver normally takes care of all the routing for you. If you find yourself needing to query the CMS for this data yourself, now you know how 💥. For more information about how routing works in Episerver CMS, I recommend reading, EPiServer 7 Routing For Dummies. Happy Coding 🤘