title: Dynamic Url rewrite in ASP.NET CORE
body: <p>I'm trying to rewrite a URL, and detect if a portion of the URL exists,
   then process that string to finally create a final URL.      </p>
  
  <p>From <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/url-rewriting?view=aspnetcore-2.1&amp;tabs=aspnetcore2x" rel="nofollow noreferrer">this article</a>, I found so far a way to replace segments of the URL using a regex.</p>
  
  <p>My case is the following:
  given the URL </p>
  
  <blockquote>
    <p>www.whatever.com/segment1/segment2?parameter=value</p>
  </blockquote>
  
  <p>I need to detect if the text "<strong>parameter=</strong>" exist in the URL and then process the value and get something like:</p>
  
  <blockquote>
    <p>www.whatever.com/segment1/segment2?parameter=valueConverted</p>
  </blockquote>
  
  <p>First, I tried doing something like:</p>
  
  <pre><code>var options = new RewriteOptions() 
    .AddRedirect("segment1/segment2/(.*)", "segment2/$1");
  </code></pre>
  
  <p>which worked fine but I was later asked to process the value of the parameter.
  But I have not found something similar to this yet:</p>
  
  <pre><code>var options = new RewriteOptions()  
    .AddRewrite(@"^param=$", "param=" MethodCall(how to send value here?) );
  </code></pre>
  
  <p>Any guidance?</p>