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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top