Extract filename from url

J

Joyjit Mukherjee

Hi,

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

Regards
Joyjit
 
D

Davide Vernole [MVP]

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

Members online

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top