title: How can I have multiple levels of paths for files with extensions (like .jpg) in routing in mvc
body: <p>I'm trying to set one controller so it can handle all of these urls:</p>
  
  <pre><code>/file/filename.jpg
  /file/path1/filename.jpg
  /file/path1/path2/filename.jpg
  </code></pre>
  
  <p>etc.</p>
  
  <p>The individual values for path1, path2, etc, will be different, and the filename.jpg will be different as well.</p>
  
  <p>I found a couple of other questions that are sort of similar but don't quite work for me.  </p>
  
  <p><a href="https://stackoverflow.com/questions/31934144/multiple-levels-in-mvc-custom-routing">Multiple levels in MVC custom routing</a></p>
  
  <p>My current routing for this is:</p>
  
  <pre><code>routes.MapRoute(
      name: "BlobStorage",
      url: "File/{*filepath}",
      defaults: new { controller = "File", action = "Index", filepath = UrlParameter.Optional },        
      namespaces: new string[] { "WebApp.Controllers" }
  );
  </code></pre>
  
  <p>This sort of works, in that if I use the url /file/path1/blarg, the controller will hit.  But if I put an extension on the blarg, it won't.  /file/path1/blarg.jpg just gives me a 404.</p>
  
  <p>I really hate to set up a bunch of index methods in the controller just to handle multiple levels of paths.</p>
  
  <p>Any ideas?</p>
  
  <hr>
  
  <p>Ok so it looks like the routing is correct but it's the file extension that is the problem.</p>
  
  <p>I tried setting it up with a number of methods to test for /path1/filename, /path1/path2/filename, /path1/path2/path3/filename, and I'm getting the same issue as with the routing code.  The problem seems to be that if I include an extension, the routing won't work.  But it works fine if I don't include an extension.</p>