Extract filename from url

  • Thread starter Thread starter Scott Reynolds
  • Start date Start date
Hi,

use the Scheme property of the Uri object. It will give you the scheme
(file, news etc.) for the Uri object.

Regards
Joyjit
 
Scott Reynolds said:
Hello!

Could someone please provide me a sample, how to extract filename
from url?

http://www.mydomain.com/eng/Default.aspx -> Default.aspx

Thanks

Scott

You can do it in different ways. A easy way could be this:

Uri uri = Request.Url;

string[] segment = uri.Segments;

int position = segment.Length - 1;

string page = segment[position];

Response.Write(page);
 
Back
Top