asp.net webforms dynamic routing


I have a table in sql server with pages and each page created has a slug. What I've been doing is foreach page in the table get the slug and do this:

routes.MapPageRoute(page.Slug, page.Slug, "~/page.aspx?id=" + page.Id, true, new System.Web.Routing.RouteValueDictionary { { "id", page.Id } });

so far this works perfectly. My issue is that this runs on global.asax file on application start so if I create a new page that mapping doesn't work unless i restart the website in iis. I was reading this post by <a href="http://haacked.com/archive/2010/01/17/editable-routes.aspx/" rel="nofollow">haacked</a> but haven't been able to get it to work yet and not sure if this would solve it, cause in theory when creating a page it should refresh automatically all routing..any ideas?

So when using RouteMagic I get the error "Object reference not set to an instance of an object" at this line:



You are probably missing dynamic compilation. Check in the sample code where it dynamically compiles the code

var assembly = BuildManager.GetCompiledAssembly("~/Config/Routes.cs"); var registrar = assembly.CreateInstance("Routes") as IRouteRegistrar;

Also, make sure Route.cs is set to Content so it doesn't statically compile.


  • How to redirect to home page after session timeout
  • Web API Basic Auth inside an MVC app with Identity Auth
  • IsAuthenticated is false! weird behaviour + review question
  • Generic/Unknown HTTP Error with response code 0 using UnityWebRequest
  • How to access meteor package name inside package?
  • Updating Dojo provide
  • Defined variables not working in javascript files when I use getScript
  • How can I display the parent menu item's description using Wordpress walkers?
  • Query to find the duplicates between the name and number in table
  • ViewController With Transparent Background Entering Current ViewController With Push Transition
  • Eloquent update method change created_at timestamp
  • $wpdb not working in file of WordPress plugin
  • Display issues when we change from one jquery mobile page to another in firefox
  • C# - Is there a limit to the size of an httpWebRequest stream?
  • Is my CUDA kernel really runs on device or is being mistekenly executed by host in emulation?
  • Different response to non-authenticated users and AJAX calls
  • Azure Cloud Service Web Role web pages do not load
  • C# - Serializing and deserializing static member
  • How to recover from a Spring Social ExpiredAuthorizationException
  • Sending data from AppleScript to FileMaker records
  • ILMerge & Keep Assembly Name
  • Perl system calls when running as another user using sudo
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • Large data - storage and query
  • WOWZA + RTMP + HTML5 Playback?
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Data Validation Drop Down Box Arrow Disappearing
  • Comma separated Values
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • How to include full .NET prerequisite for Wix Burn installer
  • Load html files in TinyMce
  • python regex in pyparsing
  • Error creating VM instance in Google Compute Engine
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • Hits per day in Google Big Query
  • coudnt use logback because of log4j
  • how does django model after text[] in postgresql [duplicate]
  • Android Google Maps API OnLocationChanged only called once
  • Is it possible to post an object from jquery to bottle.py?
  • How can I use threading to 'tick' a timer to be accessed by other threads?