title: Cannot Ignore ASHX Route
body: <p>I have an MVC web app, which inherits and is part of a Webform framework. Part of the webform framework outputs several ASHX handlers. Which, I cannot remove with <code>routes.clear()</code>, because that will remove them all together. I still need to use them.</p>
  
  <p>Here is where my problem comes in, I have, <code>&lt;link href="@Url.Action("Index", "Styles")" rel="stylesheet" type="text/css" /&gt;</code> This points to a controller which generates dynamic CSS Style Attributes. </p>
  
  <p>When the page renders the <code>Url.Action</code> looks like this - </p>
  
  <pre><code>&lt;link href="/MyLayout/Handlers/LoginStyleHandler.ashx?
        action=Index&amp;amp;controller=Styles" rel="stylesheet" type="text/css"&gt;
  </code></pre>
  
  <p>As far as trying to ignore this route here is what I have tried. None of these work. What gives? What can I do to keep the ASHX path out of my <code>Url.Action</code> HTML Helper.</p>
  
  <pre><code>routes.IgnoreRoute("{Handlers}.ashx");
  routes.IgnoreRoute("{Handlers}/{resource}.ashx/{*pathInfo}");
  routes.IgnoreRoute("TMW_LayoutPrototype/Handlers/LoginStyleHandler.ashx");
  routes.IgnoreRoute("{*allaspx}", new { allaspx = @".*\.aspx(/.*)?" });
  routes.IgnoreRoute("Handlers/LoginStyleHandler.ashx");
  routes.IgnoreRoute("{*allashx}", new { allashx = @".*\.ashx(/.*)?" });
  </code></pre>
  
  <h3>Update</h3>
  
  <p>Using the Regex tester at <a href="http://regexpal.com/" rel="nofollow">http://regexpal.com/</a> let me know that my Regex pattern <code>@".*\.ashx(/.*)?"</code> is valid. However it does not remove the handler from the MVC side of the web application. </p>
  
  <h3>Conclusion</h3>
  
  <p>The root of my problem stemmed from the web forms side of the application. Low-and-behold, inside the framework the MVC app inherited from laid a routing engine. So, my routes in MVC were getting placed at the bottom of the stack and the Webform routes were at the top.</p>
  
  <p>The ignore routes did not work, because the routes were being created on the application_start event. Ignoring nor placing my MVC routes at the top of the stack did not work, because then I would lose Session, as well as, forms auth.</p>
  
  <p>The solution was writing a constraint in the Webform routing code to stay out of my MVC application. After that all was fine in the MVC kingdom.</p>