title: How to extract the filename from a request url using Regex in ASP.NET
body: <p>I need to extract the filename + extension for any request having only a .aspx extension from within the request url. For ex. if the requested url is - <a href="http://www.abcd.com/index.aspx?a=1&amp;B=2" rel="nofollow">http://www.abcd.com/index.aspx?a=1&amp;B=2</a> then it should return index.aspx. If the requested url is <a href="http://abcd.com/products/pages/page1" rel="nofollow">http://abcd.com/products/pages/page1</a> then it should return empty.If the requested url is <a href="http://abcd.com/images/img1.gif" rel="nofollow">http://abcd.com/images/img1.gif</a> then it should return empty. </p>
  
  <p>Edit: If there is an aspx anywhere else in the url then it might pose the actual problem. but properly escaping the <code>.</code> and looking for the <code>.</code> within the url, and getting first match might solve the problem as hostname's usually dont have <code>.aspx</code> in them.</p>