Skip to content

Instantly share code, notes, and snippets.

@deeja
Last active June 15, 2017 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deeja/d9567bca09989b10ad3d9cde282c8c2f to your computer and use it in GitHub Desktop.
Save deeja/d9567bca09989b10ad3d9cde282c8c2f to your computer and use it in GitHub Desktop.
Route Table Entry viewer - Useful for viewing MVC routes that have been added to the RouteTable - Built for Sitecore
<%@ Page Language="C#" Debug="true" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>RouteTable entries</title>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<!-- Author: deeja https://github.com/deeja -->
<h1>RouteTable entries</h1>
<form id="form1" runat="server">
<div>
<table>
<tr>
<th>Url</th>
<th>Defaults</th>
<th>Contraints</th>
<th>DataTokens</th>
</tr>
<% foreach (var route in RouteTable.Routes.OfType<Route>())
{ %>
<tr>
<td><%: route.Url %></td>
<td>
<% if (route.Constraints != null) {foreach (KeyValuePair<string, object> pair in route.Constraints)
{%> <%: pair.Key %>: <%: pair.Value %><br/> <%}} %>
</td>
<td>
<% if (route.Defaults != null) {foreach (KeyValuePair<string, object> pair in route.Defaults)
{%> <%: pair.Key %>: <%: pair.Value %><br/> <%} }%>
</td>
<td>
<% if (route.DataTokens != null) {foreach (KeyValuePair<string, object> pair in route.DataTokens)
{%> <%: pair.Key %>: <%: pair.Value %><br/> <%}} %>
</td>
</tr>
<% } %>
</table>
</div>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment