title: ASP.NET Core MVC route that matches any URL containing a pattern that's possibly in the middle
body: <p>Typically, MVC routing is done by matching patterns from the start of the URL, e.g.:</p>
  <pre><code>app.UseEndpoints(endpoints =&gt;
  {
      endpoints.MapControllerRoute(name: &quot;MyRoute&quot;, pattern: &quot;my.io/{*suffix}&quot;, defaults: new { controller = &quot;MyController&quot; });
  });
  </code></pre>
  <p>But what if I wanted to define a route that would catch <em>any</em> request that contains a certain pattern, regardless of where in the URL path it may be found? Something like this:</p>
  <pre><code>app.UseEndpoints(endpoints =&gt;
  {
      endpoints.MapControllerRoute(name: &quot;MyRoute&quot;, pattern: &quot;{*prefix}/my.io/{*suffix}&quot;, defaults: new { controller = &quot;MyController&quot; });
  });
  </code></pre>
  <p>As you can hopefully see, I would like to catch any request that happens to include the pattern &quot;/my.io/&quot;, regardless of whether it's at the start of URL (like it typically is), in the middle of the URL, or at the end of the URL. In all cases, I would also like to capture the prefix and suffix, if any. Needless to say, these could vary unpredictably, which is big part of the reason I want to do this using wildcards.</p>
  <p>Is there a way to do this using MVC endpoint routing?</p>
  <p>If yes, how would the <code>[Route()]</code> attributes on <code>MyController</code> and its methods have to be written in order to be discovered by the routing subsystem?</p>
  <p>If no, what are my alternatives?</p>
  <p><strong>UPDATE</strong></p>
  <p>After some research, I determined that my problem is similar to <a href="https://stackoverflow.com/questions/55789850/how-to-use-regular-expression-to-match-part-of-url-in-route-part-webapi-net-co">this one</a>. Unfortunately, there was no definitive answer there...</p>